title: Why is `handleChangedUser` function in Form not working?
body: <p>I'm trying to edit users information. But when I do <code>handleChangedUser</code> function it doesn't work but if I change it to <code>handleNameChange</code> function it does work.</p>
  <p>How can I fix it?</p>
  <p>This is my github repo to that project: <a href="https://github.com/gumutzkn/test" rel="nofollow noreferrer">https://github.com/gumutzkn/test</a>.</p>
  <p><strong>Code:</strong></p>
  <pre><code>export default function EditUser() {
    const { users } = useContext(UserContext);
    const {
      name,
      username,
      email,
      city,
      number,
      setName,
      setUserName,
      setEmail,
      setCity,
    } = useContext(EditUserContext);
  
    function handleNameChange(e) {
      setName(e.target.value);
    }
  
    function handleUserNameChange(e) {
      setUserName(e.target.value);
    }
  
    function handleEmailChange(e) {
      setEmail(e.target.value);
      const selectedUser = users.find(item =&gt; item.id === number);
  
      selectedUser.email = e.target.value;
    }
  
    function handleCityChange(e) {
      setCity(e.target.value);
    }
  
    function handleChangedUser(e) {
      e.preventDefault();
      console.log(&quot;target hit&quot;);
      const selectedUser = users.find(item =&gt; item.id === number);
  
      selectedUser.name = name;
    }
  
    return (
      &lt;div className=&quot;edit&quot;&gt;
        &lt;h4&gt;Edit User&lt;/h4&gt;
        &lt;form onSubmit={handleChangedUser}&gt;
          &lt;div className=&quot;input-field&quot;&gt;
            &lt;label htmlFor=&quot;name&quot;&gt;Name&lt;/label&gt;
            &lt;input
              onChange={handleNameChange}
              type=&quot;text&quot;
              name=&quot;name&quot;
              value={name}
              required
            /&gt;
          &lt;/div&gt;
  
          &lt;div className=&quot;input-field&quot;&gt;
            &lt;label htmlFor=&quot;username&quot;&gt;Username&lt;/label&gt;
            &lt;input
              onChange={handleUserNameChange}
              type=&quot;text&quot;
              name=&quot;username&quot;
              value={username}
              required
            /&gt;
          &lt;/div&gt;
  
          &lt;div className=&quot;input-field&quot;&gt;
            &lt;label htmlFor=&quot;email&quot;&gt;Email&lt;/label&gt;
            &lt;input
              onChange={handleEmailChange}
              type=&quot;email&quot;
              name=&quot;email&quot;
              value={email}
              required
            /&gt;
          &lt;/div&gt;
  
          &lt;div className=&quot;input-field&quot;&gt;
            &lt;label htmlFor=&quot;city&quot;&gt;City&lt;/label&gt;
            &lt;input
              onChange={handleCityChange}
              type=&quot;text&quot;
              name=&quot;city&quot;
              value={city}
            /&gt;
          &lt;/div&gt;
          &lt;button
            style={{ margin: &quot;2rem 1rem&quot; }}
            className=&quot;btn waves-effect cyan waves-light right&quot;
            type=&quot;submit&quot;
            name=&quot;action&quot;&gt;
            Save
            &lt;i className=&quot;material-icons right&quot;&gt;send&lt;/i&gt;
          &lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    );
  }
  
  </code></pre>