Skip to content
Advertisement

Passing props between siblings

i want to share props from components to sibling children. I’ve read about React Context but can’t implement it.

My home component looks like this:

JavaScript

I have search state in SearchBar component, and need to pass it to ProductList component

JavaScript

Can someone help me to understand this?

Advertisement

Answer

You can declare the state in parent component (Home) and pass it as prop to both the child components as:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement