zustand-wrapper
v1.0.4
Published
Zustand wrapper
Downloads
15
Readme
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.