use-immer
use-immer copied to clipboard
Wrong type for `DraftFunction`?
https://github.com/immerjs/use-immer/blob/d0a2daa15a7cdc352990c52fe0fb5dfc5674a5f0/src/index.ts#L4
It currently specifies void as the return type, but you can actually return a new object, like:
const [state, updateState] = useImmer({ some: "value" });
updateState(() => ({ new: "value" }));
From my observations, it's equivalent to:
updateState({ new: "value" });
I was trying to make a wrapper for the updater function and the wrong function signature tripped me up.
Correct, encountering the same issue.
PR welcome