Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator跳转不会执行componentDidHide #1614

Closed
yjgeek opened this issue Dec 20, 2018 · 8 comments
Closed

Navigator跳转不会执行componentDidHide #1614

yjgeek opened this issue Dec 20, 2018 · 8 comments

Comments

@yjgeek
Copy link

yjgeek commented Dec 20, 2018

问题描述
我有A、B、 C 3个页面,A跳到B跳到C,其中B有个定时器,想要跳转页面时清除掉定时器,现在我发现两个怪异的现象(已在原生小程序测试过):

  1. B跳到C页面之前会想执行componentDidShow(可以看下面的gif图)
  2. B跳到C页面不会执行componentDidHide(看文档对应小程序的onHide),原生的小程序会执行

复现步骤
treedemo

// B 页面的代码
class B extends Component {
  componentDidShow () {
    console.log('调用componentDidShow')
  }
  componentDidHide () {
    console.log('清除定时器 componentDidHide')
  }
}

期望行为

报错信息

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

  • 操作系统: [e.g. Windows 7]
  • Taro 版本 [e.g. v1.2.0-beta.15]
  • Node.js 版本 [e.g. v8.9.4]
  • 报错平台 [weapp]

补充信息

@taro-bot
Copy link

taro-bot bot commented Dec 20, 2018

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@yjgeek yjgeek changed the title Navigator跳转不能触发componentWillUnmount Navigator跳转不能怪异现象 Dec 20, 2018
@yjgeek yjgeek changed the title Navigator跳转不能怪异现象 Navigator跳转怪异现象 Dec 20, 2018
@yjgeek
Copy link
Author

yjgeek commented Dec 20, 2018

只有点击导航栏的返回按钮才会触发componentDidHide

@yjgeek yjgeek changed the title Navigator跳转怪异现象 Navigator跳转不会执行componentDidHide Dec 20, 2018
@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 20, 2018

复现不了,提供一下三个页面可复现的最简代码。

2018-12-20 16_19_53

@yjgeek
Copy link
Author

yjgeek commented Dec 20, 2018

@Chen-jj 其他两个都是跳转而已,就B页面有这个逻辑,另外,这个B页面的显示是一个组件来的,不知道和这个有没有关系,
B页面的代码:

export default class B extends Component {
  render () {
    return (
      <View>
        <Child ref='child' params={this.$router.params} />
      </View>
    )
  }
}
// Child 这组的代码就是上面的代码了:
class Child  extends Component {
  componentDidShow () {
    console.log('调用componentDidShow')
  }
  componentDidHide () {
    console.log('清除定时器 componentDidHide')
  }
}

不知道这样子行么?

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 20, 2018

开发者工具调试基础库版本多少?

@yjgeek
Copy link
Author

yjgeek commented Dec 20, 2018

2.4.0

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 20, 2018

Taro cli 和项目依赖都升级到最新再试试

@yjgeek
Copy link
Author

yjgeek commented Dec 20, 2018

升级到最新版就ok了,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants