Reputation: 129
For example I have an field that needs to have an user selected, so I have another React component where I select there the value, so I have a state there, how can I send that data to the current Component I have.
Upvotes: 0
Views: 533
Reputation: 36
You can pass the value of that state as a prop:
const [selectedUser, setSelectedUser] = useState();
...
return (
<OtherComponent prop={selectedUser} />
)
and receive that prop on the other component
export default function AnotherComponent(prop) {...}
Upvotes: 1
Reputation: 1207
There are a few ways to do it.
Upvotes: 1