[英]passing props form child to parent component in react
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.在Radiooptions 我使用了一些useState 钩子,我想将该状态从Radiooptions 组件传递给它的父级(passGen),然后从那里将该状态传递给Get Button 组件以检查某些条件,如果没有错误,则生成密码。 (I'll also attach my GitHub repo for better access to my source code) (我还将附上我的 GitHub 存储库,以便更好地访问我的源代码)
https://github.com/arviinmo/palora/tree/main/components/passwordgenerator https://github.com/arviinmo/palora/tree/main/components/passwordgenerator
You can't pass props from child to parent in React, it's only one way (from parent to child).你不能在 React 中将道具从孩子传递给父母,这只是一种方式(从父母到孩子)。
You should either:您应该:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.