if Component0 has Component1 and Component2,
In Component1, there is a useState which creates items as a
useState has properties as: id, title, array(of type array)
When a
This is my first time asking a question online, for more details I have explained it in the readme file of the GitHub link
I had once got it, but later messed up everything. Don’t know what to do
3
Answers
If I understood correctly,
you can declare your state in parent component (component0) and then pass state and
setState
to both components (component 1 and 2) as props.(It’s not the best way but it works)
Hope you find the below answer useful 🙂
Patterns component
Parent component
Output component
You don’t need useState inside the Patterns component. You need to manage the state in the Parent component that has the Patterns and Output component to forward information to the child components. So create a state in the Parent component to manage the selectedItem and setSelectedItem and pass the setSelectedItem to the Patterns component and the selectedItem to the Output component. I saw your code on github and it should be something like this:
Parent component:
Patterns component:
Output component: