3 ms·
No! Never access the DOM directly if you can help it. I forgot to mention, display things like you said are one of the only places we really use local state. A
by wingspan 12y ago
No! Never access the DOM directly if you can help it. I forgot to mention, display things like you said are one of the only places we really use local state. A dropdown for instance, might have a state called "isOpen". In your click handler, you'd call this.setState({isOpen: true}), and in render, you'd only render the dropdown if isOpen is true.
- terhechte 12y agoThanks, totally makes sense now that I think about it. I just removed the offending code and set up a proper local state for it.