title: How do I display text on button click in React.js
body: <p>Have this code (below) and am trying to display the text at the click of a button in React.js.</p>
  
  <p>Heres the code:</p>
  
  <pre><code>class App extends Component{
  
  render(){ 
    alert=()=&gt;{return(&lt;h1&gt;Hi&lt;/h1&gt;)}
    return(&lt;div className="App"&gt;
      &lt;button onClick={this.alert}&gt;Enter&lt;/button&gt;
    &lt;/div&gt;);
  
  }}
  
  export default App;
  </code></pre>
  
  <p>Any ideas why it's not working...? </p>