简体   繁体   English

REACT.JS通过组件传递国家

[英]REACT.JS Passing a State through Components

这是我的情况)

I should update a state in the component 'TimeDisplay' from the component 'TaskItem' (you can see the components hierarchy as it follows. How can I implement it? 我应该从组件'TaskItem'更新组件'TimeDisplay'中的状态(您可以看到组件层次结构,如下所示。我该如何实现它?

You should really look into using Redux for global state management. 您应该真正考虑使用Redux进行全局状态管理。 It's got a bit of a learning curve but it is 100% worth it for this exact usage. 它有一点学习曲线,但对于这个确切的用法它是100%值得的。 The other way is have your state be at the top most component (Panel) and you can pass down whatever state your need to down as props to all the child components. 另一种方法是让你的状态处于最顶层组件(Panel),你可以将你需要的状态传递给所有子组件作为道具。

Redux.js Redux.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM