Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
I am assuming you are refering to sibling components OR accessing a state of a child from it's parent (those are the tricky ones) One way to go about it is having the state defined on a top level and passed along as props along with a function to update it. That's a rather straightforward solution. A better way that will require some refactoring (and some extra learning) is to add a global state management to the project, such as Redux, Mobx or any other (there are plenty out there) Redux is one of the most popular today, and Mobx is a personal favorite of mine.
23rd Apr 2020, 10:27 PM
Burey
Burey - avatar