blob: 6f21226b52ad1d22cb98fcbeca3ee968a77dab37 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import { create } from 'zustand';
const store = create(() => ({}));
const useGlobalState = (key: string, value?: any) => {
if (value !== undefined && store.getState()[key] === undefined) {
store.setState({ [key]: value });
}
return [store(state => state[key]), (value: any) => store.setState({ [key]: value })];
};
export { useGlobalState };
|