mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 05:33:29 +01:00
8 lines
257 B
TypeScript
8 lines
257 B
TypeScript
import { useCallback, useState } from 'react';
|
|
|
|
export function useToggle(initialValue = false) {
|
|
const [value, setValue] = useState<boolean>(initialValue);
|
|
const toggle = useCallback(() => setValue((v) => !v), []);
|
|
return [value, toggle] as const;
|
|
}
|