title: React update input value on button click
body: <p>I have a React component with an input field.</p>
  
  <p>I want to update the value of the input field when a button is clicked, I can confirm that the value changes when I inspect element but it doesn't display in the input field. Below is a sample code to just to give an idea.</p>
  
  <pre><code>class InputField {
   constructor(props) {
    super(props)
   }
   state = {
    userInput: ''
   }
  }
  
  onClick = () =&gt; {
   this.setState({
    userInput: 'Test'
   })
  }
  
  
  render() {
   return ( &lt;input value={this.state.userInput} name="sampleInput" /&gt;
    &lt;button onClick={this.onClick}&gt; Click me &lt;/button&gt;  
   )
  }
  </code></pre>