title: How to implement callBack function when screen change in react-native?
body: <p>I need a function when change screen executing, I mean when from screen home navigate to about screen  executing the callback function.</p>
  <h2>Scenario</h2>
  <p>I want make global stack when change any naviagte run callback function for some check like (<strong>userToken, internet state, check location is one or off, etc.</strong>)</p>
  <h2>Try this</h2>
  <p>i create a class component for <strong>Stack-navigation</strong> and implemnet <code>UNSAFE_componentWillUpdate</code>, can detected any navigate.</p>
  <p><strong>Code</strong></p>
  <pre><code>UNSAFE_componentWillUpdate(prevProp, prevState) {
      if (prevProp != this.props) {
        console.log('change state navigation');
      }
    }
  </code></pre>
  <h2>Mistake this way</h2>
  <ul>
  <li>Can not detected first screen <code>index-zero</code> <strong>Home-screen</strong>.</li>
  <li>I must write for each stack this code.</li>
  </ul>
  <h2>My Stack</h2>
  <pre><code>&lt;Stack.Navigator&gt;
      &lt;Stack.Screen
        name=&quot;Home&quot;
        component={Home}
      /&gt;
     &lt;Stack.Screen
        name=&quot;About&quot;
        component={About}
      /&gt;
  &lt;/Stack.Navigator&gt;
  </code></pre>