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.
3 Answers
There are a few ways to do it.
- Lifting state up - Documentation Link
- Using React Context API - Documentation Link
- adding that selected data to LocalStorage (can be done but not suggested) - Article Link
up the hierarchyto a module where both components may receive the state. Another idea is to employ one of severalstate managementtools (for example: redux). And, I'm sure there are other ways too (may beuseContexthook, etc).