Asyncronous setState not working in componentDidMount, but working elsewhere: React Native
<p>My plan is to get an array of strings from a http request with an authorization token in the header, and then use the array to decide what to render(multiple components means the user is an admin hence he ll be sent to a listView e.t.c)</p>

<p>How I store the authorisation token: (react-native-router-flux is used for navigation)</p>

<pre><code>    AsyncStorage.setItem('access_token',token).then((value)=&gt; { Actions.pageTwo()}).done() 
//navigates to second page
</code></pre>

<p>In the second page have </p>

<pre><code>var HotelAdminService = require('./services.js');
....
constructor(props) {
  super(props);
  this.state={
   keyLoaded:false,
  };
  this.tester= HotelAdminService.tester.bind(this); 
}

componentDidMount() {
  HotelAdminService.tester.bind(this);
 }

render() {
    console.log(this.state);
    if (!(this.state.keyLoaded) ) {
      return this.renderLoadingView();
    }
    return (
      &lt;View style={styles.viewContainer} &gt;
        &lt;SearchBar onChangeText={(e) =&gt; this.clickMovie(e)}&gt;  &lt;/SearchBar&gt;
        &lt;ListView dataSource={this.state.dataSource} renderRow=    {this.renderMovie} style={styles.listView}/&gt;
      &lt;/View&gt;
   );
 }
</code></pre>

<p>services.js:</p>

<pre><code>exports.tester=function(){
let REQUEST_URL= config.baseUrl + 'api/HotelAdmin/GetKey';


 AsyncStorage.getItem('access_token').then((value) =&gt; {

fetch(REQUEST_URL, {
method: 'GET',
headers: {
  'Authorization': 'Bearer ' + value,
 }
 }).then((response) =&gt; {return response.json()}  ).then((responseData) =&gt; {

 this.setState(
   {key: responseData,
    keyLoaded: true,
    dataSource: this.state.dataSource.cloneWithRows(responseData),
  });
  }).done();



});



}
</code></pre>

<p>Now I know this method works, as it does what I want it to do, however <strong>only when I call it from a button click from the second page</strong>. What I want to do however is to get the HotelAdmin.tester work at the begining so it can lead to a re-render when I get the data.As you can see My render method gives a loading screen until keyLoaded becomes true. Maybe one alternative would be the tester method to return a string instead of changing the state, however I was unable to return a string array from the nested promise calls.</p>

<p>In its current condition, the code stays stuck in the loading screen as HotelSystemAdmin.tester won't run and change the state</p>