当 React Native 应用程序在前台以及应用程序在后台时,如何在 React Native 中实现超时?
How to implement timeout in react native while react native application is in foreground and also if application is in background?
我遇到了 React Native 问题。我想在很长一段时间后说 20 分钟后设置状态。为此,我尝试使用 setTimeout 函数,但这给了我警告 - “长时间设置计时器,即多分钟,是 [=19= 上的性能和正确性问题] 因为它使计时器模块保持唤醒状态,并且只能在应用程序位于前台时调用计时器。"
setTimeout(() => {
this.setState({
showButton:true,
}) }, 1200000);
如何解决这个问题?有没有办法在本机反应中设置长时间超时?
任何人请帮我解决这个问题。谢谢大家。
this 似乎正是为此而创建的包
"You can use the setInterval and setTimeout functions. This API is identical to that of react-native and can be used to quickly replace existing timers with background timers."
我遇到了 React Native 问题。我想在很长一段时间后说 20 分钟后设置状态。为此,我尝试使用 setTimeout 函数,但这给了我警告 - “长时间设置计时器,即多分钟,是 [=19= 上的性能和正确性问题] 因为它使计时器模块保持唤醒状态,并且只能在应用程序位于前台时调用计时器。"
setTimeout(() => {
this.setState({ showButton:true, }) }, 1200000);
如何解决这个问题?有没有办法在本机反应中设置长时间超时? 任何人请帮我解决这个问题。谢谢大家。
this 似乎正是为此而创建的包
"You can use the setInterval and setTimeout functions. This API is identical to that of react-native and can be used to quickly replace existing timers with background timers."