In Facebook's documentation on refs
:
Don’t Overuse
Refs
Your first inclination may be to use refs to “make things happen” in your app. If this is the case, take a moment and think more critically about wherestate
should be owned in the component hierarchy. Often, it becomes clear that the proper place to “own” that state is at a higher level in the hierarchy. See theLifting State Up
guide for examples of this.
In my current React app, I have a few div
nodes that I want to modify on condition. Those div nodes were created deep inside the render()
's chained returns
. I certainly can't use Document.queryselector(). And I cannot think of anything else.
Documentation also tried to explain with article "lifting state up" but I didn't understand. Can someone shed a light on this one? (ELI5
if you could.)