我有一个 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}
.