【发布时间】:2016-12-29 21:23:28
【问题描述】:
在我的 React native 项目中,我需要检查组件何时显示在屏幕中以通过后台线程更新 UI。
我查看了组件道具规格并尝试了componentWillUnmount,componentWillMount,但它不适用于我的情况。
我也尝试过使用navigator.getCurrentRoutes(),但它返回空对象。
请帮我解决这个案子!
【问题讨论】:
-
为什么componentWillMount/componentWillUnmount 不起作用?这看起来是正确的做法。
-
你能提供更多关于你的 reactNative 项目的信息吗?一般情况下,componentWillMount 是正确的做法。
-
@ManoloSantos 我使用 F8 示例,登录 componentWillMount/componentWillUnmount ,但显示的唯一内容是 componentWillMount,导航到另一个屏幕并返回此屏幕后,没有任何反应,我想检查什么时候特别屏幕中显示的组件电流。
-
@JeffPChacko componentWillMount 工作正常,但它会发生一次,当我导航到另一个屏幕并且当前屏幕隐藏时,我如何检查组件是隐藏还是显示?
标签: reactjs react-native react-router