title: Can not implement callback inside of useFocusEffect from React-navigation
body: <p>I have React-native app with topTabNavigator with three tabs. And usually componentDidMount and componentWillUnmount lifecycle methods don't work when the user changes the tab. Therefore instead  of them I decided to use for the side effects onWillFocus and onDidFocus from React-Navigation. And before 5th version of this great library <a href="https://reactnavigation.org/" rel="nofollow noreferrer">https://reactnavigation.org/</a> it was possible to import NavigationEvents  component and put it to the view with focused callbacks:</p>
  
  <pre><code>import { NavigationEvents } from 'react-navigation';
  
  class MyTeamScreen {
    const store = this.props.store;
    const members = store.members;
  
    return (
    &lt;View&gt;
      &lt;NavigationEvents
        onWillFocus={payload =&gt; store.getTeamMebers()}
        onDidFocus={payload =&gt; store.dispose()}
      /&gt;
      &lt;MymebersList team={members} /&gt;
    &lt;/View&gt;
   );
  }
  export default MyScreen;
  </code></pre>
  
  <p>But at the moment there is no like this way after the upgrade of react reactnavigation library, because NavigationEvents is deprecated. And only one way to use useFocusEffect. And this is my hook:</p>
  
  <pre><code>function FetchMembers(store) {
    useFocusEffect(
    React.useCallback(() =&gt; {
        return () =&gt; store.getMembers();
      }, [store])
    );
  
    return null;
  }
  
  </code></pre>
  
  <p>Class component:</p>
  
  <pre><code>class MyTeamScreen {
    const store = this.props.store;
    const members = store.members;
  
    return (
    &lt;View&gt;
      &lt;FetchMembers store={store} /&gt;
      &lt;MymebersList team={members} /&gt;
    &lt;/View&gt;
   );
  }
  </code></pre>
  
  <p>But I'm getting the error:</p>
  
  <p><a href="https://i.stack.imgur.com/5QkTu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5QkTu.png" alt="enter image description here"></a></p>
  
  <p>And I checked the store was initialized inside of the hook, but it can not call a method from it, because it's undefined.
  Can you tell me please what I'm doing wrong? Is it a good way to use react-navigation methods instead of lifecycles componentDidMount and componentWillUnmount? Or maybe you could recommend me please the better way how to implement side effect when the user is changing the tab?</p>