title: Fill Inputfield automatically
body: <p>I have a React application and in it I have an input field. I work with Bootstrap. When the user clicks a button, I want the input field to be filled automatically. So at the beginning it should be empty, because the variable <code>name = &quot;&quot;</code> and as soon as the button is pressed the name <code>Max</code> should be in the input field, how do I do that?</p>
  <p>My Code</p>
  <pre><code>const Profile = () =&gt; {
  
  const [name, setName] = useState();
  const onClickBack = () =&gt; {
      setName('Max');
  }
  
  
  return (
      &lt;div&gt;
  
            &lt;div className=&quot;form-group&quot;&gt;
                &lt;div className=&quot;col-xs-4&quot;&gt;
                  &lt;label for=&quot;exampleInputName&quot;&gt;Name&lt;/label&gt;
                    &lt;input
                           type=&quot;text&quot;
                           className={name ? &quot;form-control&quot; : &quot;form-control is-invalid&quot;
                          }
                          placeholder={name}
                         onChange={(event) =&gt;
                         setValueName(event.target.value)
                         }  
                         // text = {name} // not working                    
                                                      
                    /&gt;
               &lt;/div&gt;
             &lt;/div&gt;
             &lt;button
                type=&quot;button&quot;
                id=&quot;submit&quot;
                name=&quot;submit&quot;
                className=&quot;btn btn-primary submit-button ml-5&quot;
                onClick={onClickBack}
                 &gt;
                Back
             &lt;/button&gt;
  
      &lt;/div&gt;
  );
  };
  
  export default Profile;
  </code></pre>