score:8

Accepted answer

You can make use of componentDidMount function to call an api (if you want to call it only once) that returns you the data which you can save in the state and render

class App extends React.Component {
    state = {
      data: [],
      loading: true
    }
    componentDidMount() {

       ApiCall().then((data) => {
           this.setState({data, loading: false})
       })
    }
    render() {
      if(this.state.loading) {
          return 'Loading...'
      } 
      return (
         <View><Text>{this.state.data.map((obj => <View>{/* return that you want here from obj*/}</View>))}</Text></View>
      );
    }
}

To enhance UserExperience, you can have a loading state till your data is ready.


Related Query

More Query from same tag