@practicaljs/ts-kit
v0.1.1
Published
Set of TS utilities to use with or without react
Downloads
2
Readme
Usage
Create Reducer and Actions
type User = {
name: string,
age: number
}
const UserActions = {
setName: (state: User, {payload}: Action<string>) => {
return { ...state, name: payload };
}
} satisfies ReducerActions<User>
const [state, dispatch] = useReducer(createReducer(UserActions), initState)
const actions = createActions(UserActions, dispatch)
actions.setName('foo')