title: Rendering new component on click in react
body: <p>I'm practicing react and trying to render a new component on click of a button. Here the first page is email and the component i want to render contains password page.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  class App extends React.Component {
   passwordpage(){
      return(
        &lt;form&gt;
          &lt;div className="mainapp"&gt;
            &lt;h2&gt; Password&lt;/h2&gt;
            &lt;input type='Password' className="inputpassword" placeholder='Enter Password' required/&gt;
            &lt;div&gt;
              &lt;button type="submit" className="loginbutton"&gt;Next&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/form&gt;
      );
    };
  
    render() {
      return (
        &lt;form&gt;
          &lt;div className="mainapp"&gt;
            &lt;h2&gt;Email  Id&lt;/h2&gt;
            &lt;input type='email' ref='enteremail'className="inputemail" placeholder='Enter Username' required/&gt;
            &lt;div&gt;
              &lt;button type="submit" onClick={this.props.passwordpage} className="loginbutton"&gt;Next&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/form&gt;
  
      );
    }
  }
  
   ReactDOM.render(&lt;App/&gt;,document.getElementById('app'));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react-dom.min.js"&gt;&lt;/script&gt;
  &lt;div id="app"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>