简体   繁体   English

是否可以重新加载顶级React Native组件以刷新所有子组件?

[英]Possible to reload top-level React Native component in order to refresh all children components?

I'm working on an iPad app that needs to reset itself at midnight each night. 我正在开发一个iPad应用程序,该应用程序需要在每晚的午夜重置自己。 Most of the children components contain data that needs to be wiped or refreshed for the new day. 大多数子组件都包含新一天需要擦除或刷新的数据。 Is it possible to reload (forceUpdate() didn't do the trick) the whole app programmatically? 是否可以通过编程方式重新加载整个应用程序(forceUpdate()不能解决问题)?

I realize it's counter to the React paradigm, but seems overly complicated to change some dummy state in all the children to reset them! 我意识到这与React范式背道而驰,但是要更改所有子代中的虚拟状态以重置它们似乎过于复杂!

Thanks! 谢谢!

forceUpdate()是一个生命周期函数,但是除非没有办法,否则最好不要使用它来更新子组件,而应使用setState来更新子组件。

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

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