mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 03:10:17 -04:00
8 lines
244 B
TypeScript
8 lines
244 B
TypeScript
import { useCallback, useState } from 'react';
|
|
|
|
export default function useToggle(initial: boolean) {
|
|
const [value, setValue] = useState(initial);
|
|
const toggle = useCallback(() => setValue((v) => !v), []);
|
|
return [value, toggle] as const;
|
|
}
|