Skip to content

sandimrizalul/zustand-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published