title: React: Persisting state in tabs
body: <p>I'm making a react thing with tabs. Each tab has it's own state that I need to persist between tab changes, but when I switch tabs I lose it.</p>
  
  <p>Currently when I'm adding a new tab I do something like this:</p>
  
  <pre><code>var tab = &lt;Tab hash={hash} /&gt;
  this.setState({
      tabs: this.state.tabs.concat([tab]),
      tab: this.state.tabs.length
  });
  </code></pre>
  
  <p>And when I render I do something like this:</p>
  
  <pre><code>var tab = null;
  if (this.state.tab !== null)
      tab = this.state.tabs[this.state.tab];
  return ( &lt;div&gt;{tab}&lt;/div&gt; );
  </code></pre>
  
  <p>Another question suggests passing a boolean to decide whether to display it or not, but as far as I can see, there's no way to do it this way.</p>