True, it replaces the whole state, but I do prefer to have an object on state instead N variables, (depending the case), but I think this is personal preferences.
When I set states with objects, I usually update it like (e.g):
setData(data => ({ ...data, someUpdate: “ok” });
This way I get the current state value, add it to my object, and update what I want on it... keeping it immutable.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
True, it replaces the whole state, but I do prefer to have an object on state instead N variables, (depending the case), but I think this is personal preferences.
When I set states with objects, I usually update it like (e.g):
This way I get the current state value, add it to my object, and update what I want on it... keeping it immutable.