MCPcopy Create free account
hub / github.com/dailydotdev/apps / useToggle

Function useToggle

packages/shared/src/hooks/useToggle.ts:7–18  ·  view source on GitHub ↗
(initialState)

Source from the content-addressed store, hash-verified

5) => readonly [boolean, (forced?: boolean) => void];
6
7export const useToggle: UseToggle = (initialState) => {
8 const [state, setState] = useState(initialState);
9 const toggle = (forced?: boolean) => {
10 if (typeof forced === 'boolean') {
11 setState(forced);
12 return;
13 }
14
15 setState((value) => !value);
16 };
17 return [state, toggle] as const;
18};

Callers 9

ShowMoreContentFunction · 0.90
useFunnelNavigationFunction · 0.90
PopoverFormContainerFunction · 0.90
useStreakRecoverFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected