title: Call function on application load in React Native
body: <p>I have a React Native application and it has tabbed layout. I need to call some function when the main screen is loaded. I tried to use <code>componentWillMount()</code> function, but it didn't work because my screen was defined in function and not in class. How can I create on load function?</p>
  
  <p><strong>HomeScreen.js</strong></p>
  
  <pre><code>import React, { useState, Component } from 'react';
  import { View, Text } from 'react-native';
  import { getText } from '..components/getText';
  
  export default function HomeScreen() {
  
    const [onLoadText, setText] = useState("");
  
    const onScreenLoad = () =&gt; {
      setText(getText());
    }
  
    const componentWillMount = () =&gt; {
      // Not working
      onScreenLoad();
    }
  
    return (
      &lt;View style={styles.container}&gt;
        &lt;Text&gt;{onLoadText}&lt;/Text&gt;
      &lt;/View&gt;
    );
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      backgroundColor: '#fff',
    },
  });
  </code></pre>