将道具通过react中的父母成分形成父母
return
<div>
<RadioOptions />
<GenButton />
<OutputPass />
</div>
我最近从事侧面项目,在代码中发现了一个问题。 inradioptions&nbsp;我使用了一些usestate钩子,我想将该状态从RadioOptions组件传递给其父(PassGen),然后从那里传递该状态,通过该状态toget按钮组件检查某些条件,如果没有错误的话,请生成密码。 (我还将附加我的github存储库以更好地访问我的源代码)
https://github.com/arviinmo/palora/tree/main/main/components/passwordgenerator
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能将道具从孩子传递给父母,这只是一种方式(从父母到孩子)。
您都应该:
You can't pass props from child to parent in React, it's only one way (from parent to child).
You should either:
对于新来者,这样做是这样做的:
父零件:
子组件:
For the newcomers here do it so:
Parent component:
Child component: