@practicaljs/ts-kit
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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')

/@practicaljs/ts-kit/

    Package Sidebar

    Install

    npm i @practicaljs/ts-kit

    Weekly Downloads

    5

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    6.43 kB

    Total Files

    9

    Last publish

    Collaborators

    • rcanfield
    • harlenalvarez