title: react setState with dynamic key
body: <p>I have the following snippet of code:</p>
  
  <pre><code>onChange(e) {
      e.persist
      this.setState((prevState) =&gt; {
        prevState[e.target.id] =  e.target.value
        return prevState
      })
    }
  </code></pre>
  
  <p>the how would i set the state for each key using something like the code above.</p>
  
  <p>this is the initial state:</p>
  
  <pre><code> this.state = {
        heading: this.props.match.params.length &gt; 1 ? "Edit Post" : "Create Post",
        title: '',
        category: '',
        body: '',
        author: ''
      }
  </code></pre>