18 lines
No EOL
589 B
TypeScript
18 lines
No EOL
589 B
TypeScript
import { create } from 'zustand';
|
|
|
|
interface AppStore {
|
|
hideTabsNav: Record<string, boolean>;
|
|
setHideTabsNavKey: (key: string, hide: boolean) => void;
|
|
}
|
|
|
|
export const useAppStore = create<AppStore>((set) => ({
|
|
hideTabsNav: {},
|
|
// Writing the value a key already has would still allocate a new map and
|
|
// wake every subscriber (the tab navigator included), so bail out instead.
|
|
setHideTabsNavKey: (key: string, hide: boolean) =>
|
|
set((state) =>
|
|
state.hideTabsNav[key] === hide
|
|
? state
|
|
: { hideTabsNav: { ...state.hideTabsNav, [key]: hide } }
|
|
),
|
|
})); |