React Navigation on tab change

后端 未结 5 1249
清歌不尽
清歌不尽 2021-02-08 12:58

Without using Redux, how do I detect a tab change with a react navigation tab navigator?

I know I need to somehow use onNavigationStateChange but I can\'t figure out

5条回答
  •  自闭症患者
    2021-02-08 13:53

    And if you intend to use the Window properties, you can easily do this in react.

    Keep a check whether window is present before return inside of render.

    if (typeof window !== "undefined") {
    window.addEventListener('visibilitychange, () => {
    window.document.title = window.document.hidden;
    console.log(document.hidden ? "Out" : "In");
    this.props.doFunction();
    

    }

提交回复
热议问题