Moved collapse button.
This commit is contained in:
13
src/components/hooks/useGlobalState.ts
Normal file
13
src/components/hooks/useGlobalState.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user