title: How can I show loader in react-native until the response is fetched
body: <p>In my react-native application, I am populating the data in <code>componentDidMount</code>. However there is some delay until I get the data so I want to show the loader until then. To do that, I am using Activity Indicator.</p>
  
  <p>My code-</p>
  
  <pre><code>    import {
        Switch,
        ScrollView,
        StyleSheet,
        Text,
        Image,
        View,
        TouchableOpacity,
        ActivityIndicator
      } from 'react-native';
  
          class AccordionView extends Component {
            state = {
              activeSections: [],
              newData: []
            };
  
  
               _renderContent = section =&gt; {
                  return (
                    &lt;View style={styles.content}&gt;
                      &lt;Text&gt;{section.content}&lt;/Text&gt;
                    &lt;/View&gt;
                  );
                };
          }
  
     render() {
         if (!this.state.newData) {
            return (
              &lt;ActivityIndicator
                animating={true}
                style={styles.indicator}
                size="large"
              /&gt;
            );
          }
  else if (this.state.newData.length === 0){
     return &lt;Text&gt;No records found!!&lt;/Text&gt; 
  }
  else{
      return (
                &lt;Accordion
                  sections={this.state.newData}
                  activeSections={this.state.activeSections}
                  renderSectionTitle={this._renderSectionTitle}
                  renderHeader={this._renderHeader}
                  renderContent={this._renderContent}
                  onChange={this._updateSections}
                /&gt;
              );
            }
          }
  }
  </code></pre>
  
  <p>CSS-</p>
  
  <pre><code>indicator: {
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
          height: 80
        }
  </code></pre>
  
  <p>My <code>newData</code> has the updated response after the api call hence I am doing something like above but I do not see any Indicator/Loader on my page load until the data is fetched. Can someone let me know how can I achieve this?</p>