Suppose if we want to maintain all the fields in a single useState then we can maintain a object inside the useState fxn but when updating we have to remember that we cant update like
setform(event.target.value) bcz it will overwrite all the value with only one value then we have to use the spreding operator
(… ) is called the spreading operator
this is for appending something to the existing one
we will use it so that we can update a single value inside a object without losing all other values
setform(…form , userTitle:event.target.value)→ means update only the useTitle inside the object and all other value remains same as they are
There may be something problematic when you are
appending the previous value with the new data . There is a probability that when you write three or four statements in line by line they will not executed in the same manner so we have to look after that
we can use the fxn so that it will return the value then only the next one gets executed ⇒
we have to use this type of format