zustand-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

zustand-wrapper

Just a wrapper for zustand.

Installation

yarn add zustand-wrapper

Usage

import { MMKV } from 'react-native-mmkv';
import {create} from 'zustand';
import useZustandWrapper from 'zustand-wrapper';
import {createJSONStorage, persist} from 'zustand/middleware';

const appPersistStorage = new MMKV();

interface IMyStore {
  data: any;
  setData: (val: any) => void;
}

const useMyStore = create<IMyStore>()(
  persist(
    set => ({
      data: [],
      setData: (val: any) => set(() => ({data: val})),
    }),
    {
      name: 'my-storage',
      storage: createJSONStorage(() => useZustandWrapper(appPersistStorage)),
    },
  ),
);

export default useBoardStore;

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

🔗 Links

linkedin

Package Sidebar

Install

npm i zustand-wrapper

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

2.45 kB

Total Files

3

Last publish

Collaborators

  • sandimrizalul
  • purplereborn