1.0.4 • Published 3 months ago

zustand-wrapper v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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

1.0.2

3 months ago

1.0.1

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.0

3 months ago