use-immer

  • Version 0.10.0
  • Published
  • 26.9 kB
  • No dependencies
  • MIT license

Install

npm i use-immer
yarn add use-immer
pnpm add use-immer

Overview

Use immer with React hooks

Index

Functions

function useImmer

useImmer: <S = any>(initialValue: S | (() => S)) => ImmerHook<S>;

    function useImmerReducer

    useImmerReducer: {
    <S, A, I>(
    reducer: ImmerReducer<S, A>,
    initializerArg: S & I,
    initializer: (arg: S & I) => S
    ): [S, Dispatch<A>];
    <S, A, I>(
    reducer: ImmerReducer<S, A>,
    initializerArg: I,
    initializer: (arg: I) => S
    ): [S, Dispatch<A>];
    <S, A>(reducer: ImmerReducer<S, A>, initialState: S, initializer?: undefined): [
    S,
    Dispatch<A>
    ];
    };

      Type Aliases

      type DraftFunction

      type DraftFunction<S> = (draft: Draft<S>) => void;

        type ImmerHook

        type ImmerHook<S> = [S, Updater<S>];

          type ImmerReducer

          type ImmerReducer<S, A> = (
          draftState: Draft<S>,
          action: A
          ) => void | (S extends undefined ? typeof nothing : S);

            type Reducer

            type Reducer<S = any, A = any> = ImmerReducer<S, A>;
            • Deprecated

              Use ImmerReducer instead since there is already a Reducer type in @types/react.

            type Updater

            type Updater<S> = (arg: S | DraftFunction<S>) => void;

              Package Files (1)

              Dependencies (0)

              No dependencies.

              Dev Dependencies (4)

              Peer Dependencies (2)

              Badge

              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/use-immer.

              • Markdown
                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/use-immer)
              • HTML
                <a href="https://www.jsdocs.io/package/use-immer"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>