I
I
Igor Shumilovsky2016-03-09 12:02:10
React
Igor Shumilovsky, 2016-03-09 12:02:10

Is using querySelector() in ReactJs wrong?

Let's say there is a button, by clicking on which a popup will open. How to get to the popup in React if it is three nine lands away from the button and in a completely different component tree?
Refs? JS selectors?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2016-03-09
@JiSeven

Describe a little more what you want to do. How does a popup open - does it just have an "open"/"closed" property, or is it a method that needs to be called? In a good way, the state of this popup descends from top to bottom through `props`.
To avoid building long ladders of props, check out Context in React.
If querySelector() is needed - i.e. get the DOM element itself - i.e. ReactDOM.findDOMNode() .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question