mirror of
https://github.com/mountain-loop/yaak.git
synced 2025-12-23 22:48:55 -05:00
8 lines
267 B
TypeScript
8 lines
267 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, setValue] as const;
|
|
}
|