create-zustand-store-context
v1.1.18
Published
Create React context with Zustand Store
Downloads
80
Readme
create-zustand-store-context
AbortController hook
Install
npm install --save create-zustand-store-context
Usage
import { createZustandStoreContext } from "create-zustand-store-context";
type Store = {
value: boolean;
};
const initialState: Store = {
value: false,
};
const { storeContext, useState, useStore } =
createZustandStoreContext<Store>(initialState);
const StoreContext = storeContext;
function Provider({ children }: WithChildren) {
const currentStore = useStore();
return (
<StoreContext.Provider value={currentStore}>
{children}
</StoreContext.Provider>
);
}
export { Provider, useState };
License
MIT © marcoSven