mirror of
https://github.com/umami-software/umami.git
synced 2026-02-23 14:05:35 +01:00
13 lines
356 B
TypeScript
13 lines
356 B
TypeScript
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 };
|