return
<div>
<RadioOptions />
<GenButton />
<OutputPass />
</div>
I recently worked on my side-project and I found an issue in my code. inRadiooptions I used some useState hooks, and I want to pass that state from Radiooptions component to its parent(passGen) and then from there, pass that state toGet Button component to check some condition and if nothings wrong, generate the password. (I'll also attach my GitHub repo for better access to my source code)
https://github.com/arviinmo/palora/tree/main/components/passwordgenerator
CodePudding user response:
You can't pass props from child to parent in React, it's only one way (from parent to child).
You should either:
- Put the state in the parent component and manipulate it from the child component by passing the setter function in the props
- Use something like Redux Toolkit to create a global state that all components can have access to