mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
13 lines
347 B
TypeScript
13 lines
347 B
TypeScript
import { create } from 'zustand';
|
|
|
|
const store = create(() => ({}));
|
|
|
|
const useGlobalState = (key: string, value?: any) => {
|
|
if (value !== undefined && !store.getState()[key]) {
|
|
store.setState({ [key]: value });
|
|
}
|
|
|
|
return [store(state => state[key]), (value: any) => store.setState({ [key]: value })];
|
|
};
|
|
|
|
export default useGlobalState;
|