title: React Functional components Form handling with object in state
body: <p>So im trying to create a form with functional components in React. I have a state which contains an object </p>
  
  <pre><code>const [event, setEvent] = useState(props.location.event);
  {
      "id": 1,
      "limit": 2000,
      "price": 10,
      "accessLvl": 0,
      "details": "Event that contains all the fields",
      "duration": 24,
      "eventType": 1,
      "eventLocation": "asdasd",
      "creator": 1,
      "startDate": "2020-06-01T12:00:00",
      "title": "Testing update",
      "imageUrl": "d0659c5e-7ca1-4b02-b148-6221d6e7d7a8"
  }
  </code></pre>
  
  <p>It is a edit form so i have the input values set to these variables. With class component i could do it easily but with functional component when i try to change one variable for example title and the object is only going to contain the title which is not the behavior that i want.</p>
  
  <pre><code>&lt;input type="text" className="form-control" value={props.event.title} onChange={e =&gt; props.onTodoChange(e.target.value, "title")} id="EventTitle" /&gt;
  
    function onTodoChange(value, key) {
      setEvent({[key] : value})
    }
  </code></pre>