title: React setState: set a nested property by string
body: <p>I'm facing something strange in React, and I think that might be possible to do it but I don't know how.</p>
  
  <p>My goal: update a specific attribute of my component state, that can be a nested attribute. But! I want to update it dynamically (working with a onChange call on a bunch of inputs, don't want to code 30 onChange functions, I want to code a generic one).</p>
  
  <p><strong>Example that works:</strong></p>
  
  <pre><code>this.state = { value: 0 }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>var attribute = 'value'
  var value = 'myvalue'
  this.setState({[attribute]:value})
  </code></pre>
  
  <p><strong>Example that does not work:</strong></p>
  
  <pre><code>this.state = { nested: { value: 0 } }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>var attribute = 'nested.value'
  var value = 'myvalue'
  this.setState({[attribute]:value})
  </code></pre>
  
  <p>I can have potentially as many nesting levels as possible. I want to find a generic and easy to afford method to deal with it.</p>
  
  <p>I created a JSFiddle wich reproduces this problem as I'm trying to implement it, with onchange function: <a href="http://jsfiddle.net/n61kv6gy/" rel="nofollow">http://jsfiddle.net/n61kv6gy/</a></p>
  
  <p>Does anyone has an idea?</p>