how to set value on button click in react js?
<p>I want to change the state value on button click using react js.I am able to get click event .But the set value not updated why .I used this </p>

<pre><code>btnClick(){
    alert('---')
  //  this.setState({data: 'nannsd'});
     this.state ={data: 'sds'};
  }
</code></pre>

<p>here is my code
<a href="http://codepen.io/naveennsit/pen/MydPJM" rel="nofollow">http://codepen.io/naveennsit/pen/MydPJM</a></p>

<pre><code>class App extends React.Component{
  constructor(){
     super();
    this.state ={data: 'test'};
  }
  btnClick(){
    alert('---')
  //  this.setState({data: 'nannsd'});
     this.state ={data: 'sds'};
  }

  render(){
    return &lt;div&gt;
      hello {this.state.data}
      &lt;button onClick={this.btnClick}&gt;click&lt;/button&gt;
    &lt;/div&gt;
  }

}

React.render(&lt;App/&gt;,document.getElementById('app'))
</code></pre>