5
Knowing that Reactjs uses a virtual DOM where elements are processed into a DOM representation in memory so that all changes are made faster then it would be "wrong" to use findDOMNode to directly access an DOM element and manipulate its state?
5
Knowing that Reactjs uses a virtual DOM where elements are processed into a DOM representation in memory so that all changes are made faster then it would be "wrong" to use findDOMNode to directly access an DOM element and manipulate its state?
6
Yes, it would be wrong.
findDOMNode
only exists for reading DOM information (eg: position, form fields value, etc). Modify the DOM
directly can also generate inconsistencies, because the view that the framework
has the DOM (virtual-dom)
will not be the same as DOM
in the browser, then it may end up overwriting the values you manually set.
Browser other questions tagged javascript react
You are not signed in. Login or sign up in order to post.
So just to be clear, with respect to getting the value of an input text the most correct way would be findDOMNode? Because the first tests I’ve been doing with React I was doing a bigger gambiarra in the world with events not to access the DOM directly.
– Henri Cavalcante
Nice surprise to see you here @fabiomcosta!
– Sergio