Manipulating DOM with native JS is not recommended. If you really need this capability, you can get the reference to the DOM node through ReactDOM’sfindDOMNodemethod. For example here: https://facebook.github.io/re...
But this is indeed a potentially risky behavior [opening a safe door]. The operation of directly modifying the DOM through native JS is redundant, unsafe and inconsistent with React ideas. It is recommended to consider the problem to be solved in the form of JSX.
Manipulating DOM with native JS is not recommended. If you really need this capability, you can get the reference to the DOM node through ReactDOM’s
findDOMNode
method. For example here:https://facebook.github.io/re...
But this is indeed a potentially risky behavior [opening a safe door]. The operation of directly modifying the DOM through native JS is redundant, unsafe and inconsistent with React ideas. It is recommended to consider the problem to be solved in the form of JSX.
There must be other ways to do it. You can consider the classnames package. The ref used upstairs is also a common method