DEV Community


Discussion on: Feature request: [state,,updateState] = useState(...)

benvds profile image
Ben van de Sande

I think it is not added because this is "standard" merge function and out of scope of react as a rendering library. It is easily written yourself and a lot of utility libraries like lodash also include this function.

The recommended way for splitting state variables is: "...split state into multiple state variables based on which values tend to change together." -

I think this is because every state change triggers a render. Therefore you probably also see { loading, data, error } variables combined; because they are mostly updated together.