title: Reactjs SPA app - Everything as a component (Performance and practices)
body: <p>I see that react fits well when you want to "componentize" small parts of your application, but I'm not sure about making a full component application, let's say a SPA.</p>
  
  <p>In my example I have a single page with a menu and a content place for the "views" that are other components as well.</p>
  
  <p>The way I found to solve that is to build a menu component and on its render method I check what option has been chosen and display this in this content place, its nothing but a switch case inside the render method (Smells but easily to fix)</p>
  
  <pre><code>var MenuComponent = React.createClass({
    getInitialState: function() {
      return { selectedPage: '' }
    },
    handleMenuClick: function(e) {
      this.setState({ selectedPage: e.target.attributes['data-page'].value});
    },
    render: function() {
      return (
        &lt;div className='main'&gt;
          &lt;ul class='menu'&gt;
            &lt;li&gt;&lt;button onClick={this.handleMenuClick} data-page='applicantList'&gt;Applicant List&lt;/button&gt;&lt;/li&gt;
            &lt;li&gt;&lt;button onClick={this.handleMenuClick} data-page='applicantForm'&gt;Applicant Form&lt;/button&gt;&lt;/li&gt;
          &lt;/ul&gt;
          &lt;div className='content'&gt;
            {function() { 
              switch(this.state.selectedPage) {
                case 'applicantList':
                  return &lt;ApplicantList /&gt;
                case 'applicantForm':
                  return &lt;ApplicantForm /&gt;
                default:
                  return &lt;h1&gt;Select a Page&lt;/h1&gt;
              };
            }.bind(this)()}
          &lt;/div&gt;
        &lt;/div&gt;
      );
    }
  });
  </code></pre>
  
  <p>From that point I imagine everything being a component and having their children components and so on. I want to know if this approach is a good practice and if it has drawbacks like performance or maintainability (I found it far easier for unit testing).</p>