react-navigation: Detect when screen, tabbar is activated / appear / focus / blur

前端 未结 5 1301
无人共我
无人共我 2020-12-07 22:44

Perviously when I wanted to make some actions when screen is opened I put them inside componentDidMount. For example I can fetch some data.

like this.

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 23:32

    componentDidMount / componentWillUnmount does not work in all cases of navigation (like tabs).

    You need to use addListener with events didFocus and didBlur to make such actions. See documentation for details

提交回复
热议问题