【发布时间】:2023-04-05 23:07:01
【问题描述】:
我有一个 expo 应用程序,我想在 5 分钟后实现自动注销。
在我创建的用户登录时显示的第一个组件中:
下面的代码可以正常工作,但是当我切换到新屏幕(新组件)时,我无法更新注销时间。
如何在下一个屏幕上更新时间?
componentWillMount() {
this._panResponder = PanResponder.create({
onMoveShouldSetPanResponderCapture: () => {
clearTimeout(this.timeout)
this.setState((state) => {
if (state.inactive == false) return null
return {
inactive: false
}
})
this.timeout = setTimeout(() => {
this.setState({
inactive: true
})
}, 300000)
return false
}
})
}
componentWillUnmount() {
clearTimeout(this.timeout)
}
在屏幕上,我输入了{... this._panResponder.panHandlers}。
【问题讨论】:
标签: reactjs settimeout native logout panresponder