little-state-machine
little-state-machine copied to clipboard
Type Error for actions without a payload.
I have issues with actions which have no payloads (eg. init or reset functions)
import { useStateMachine } from "little-state-machine";
export type GlobalState = {
stateValue: string;
};
const defaultState: GlobalState = {
stateValue: "value"
};
export default function Example() {
const { actions } = useStateMachine({
reset: () => {...defaultState} // <--- Action without payload
});
actions.reset() // <--- Type Error: expects a payload argument
return null
}
Reason:
export declare type ActionsOutput<TCallback extends AnyCallback, TActions extends AnyActions<TCallback>> = {
[K in keyof TActions]: (payload: Parameters<TActions[K]>[1]) => void;
};