My structure is as such:
<ParentComponent />
<Child 1 /> <Child 2 />
I have a function in <Child 1 />
. Since <Child 1 />
controls the grid-layout, and <Child 2 />
is a Navbar with buttons, I want to have a button in <Child 2 />
which will reset some parameters in <Child 1 />
.
How do I achieve this? As far as I can see, refs
will only be able to go one "step" up the tree, not down.
There isn't any obvious way this function can be invoked from the parent
component. Is there any way here? All the solutions I can think of aren't really following the React-mindset, namely the unidirectional data-flow.