js-newbee / taro-yanxuan

首个 Taro 多端统一实例 - 网易严选(小程序 + H5 + React Native) - By 趣店 FED
MIT License
2.65k stars 562 forks source link

进入pages/user/user页面后,再去点击其他页面,Activity组件的定时器一直在运行呢 #60

Closed FuYiCai closed 4 years ago

FuYiCai commented 4 years ago

进入pages/user/user页面后,再去点击其他页面,Activity组件的定时器一直在运行呢

FuYiCai commented 4 years ago

找到了把componentDidMount() { this.timer = setInterval(() => { this.setState({ active: !this.state.active }) }, 600) }

componentWillUnmount() { if (this.timer) { clearInterval(this.timer) } }

换成componentDidShow 和 componentDidShow就好了