title: Show loader when button is clicked in react native
body: <p>I'm trying to implement the loader animation in my react native app but it does't trigger the loader when the button is clicked, although the animating already change to <code>true</code>.</p>
  
  <p>Check out my code below.</p>
  
  <pre><code>componentWillMount(){
      this.hideLoader();
  }
  
  showLoader = () =&gt; { this.setState({ showLoader:true }); };
  hideLoader = () =&gt; { this.setState({ showLoader:false }); };
  
  doSignup = () =&gt; {
      this.showLoader();
  }
  
  render() {
      console.log(this.state.showLoader);
      return (
          &lt;View&gt;
              &lt;TouchableOpacity style={{ marginTop: 25 }} onPress={this.doSignup}&gt;
                &lt;View style={[ styles.button, { backgroundColor: '#5a0060' } ]}&gt;
                  &lt;Text style={{ fontSize: 20, color: Colors.white }}&gt;Sign Up Now&lt;/Text&gt;
                &lt;/View&gt;
              &lt;/TouchableOpacity&gt;
  
              &lt;View style={{ position: 'absolute', top: 0, bottom: 0, right: 0, left: 0 }}&gt;
                &lt;ActivityIndicator animating={this.state.showLoader} size="small" color="#00ff00" /&gt;
              &lt;/View&gt;
          &lt;/View&gt;
      );
  }
  </code></pre>
  
  <p>When the screen is loaded, I set the loader animation as <code>false</code>. When the button is clicked only set to <code>true</code> which should be able to animate the loader but it doesn't appear.</p>