Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@use-rematch/plugin-store

qidanta11.0.0TypeScript support: included

save state to localstorage and recover from localstorage

readme

@use-rematch/plugin-store

save state to localstorage and recover from localstorage

install

pnpm i @use-rematch/core @use-rematch/plugin-store

usage

import { useRematch } from '@use-rematch/core';
import { createPluginStore } from '@use-rematch/plugin-store'

const PluginStore = createPluginStore()

const useHook = () => {
  const { state, dispatch } = useRematch({
    name: 'use-rematch-reducer',
    state: {
      cnt: 0,
      loading: false,
    },
    reducers: {
      add: (state) => {
        return {
          ...state,
          cnt: state.cnt + 1,
        };
      },
    },
  }, { plugins: [PluginStore] });
  return { state, dispatch }
}