|
export type DraftFunction<S> = (draft: Draft<S>) => void; |
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.
use-immer/src/index.ts
Line 4 in d0a2daa
It currently specifies
voidas the return type, but you can actually return a new object, like:From my observations, it's equivalent to:
I was trying to make a wrapper for the updater function and the wrong function signature tripped me up.