mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
19 lines
395 B
TypeScript
19 lines
395 B
TypeScript
import { useState } from 'react';
|
|
|
|
const useToggle = (defaultValue: boolean = false) => {
|
|
const [isShowing, setIsShowing] = useState<boolean>(defaultValue);
|
|
|
|
const toggle = () => setIsShowing((value) => !value);
|
|
const open = () => setIsShowing(true);
|
|
const close = () => setIsShowing(false);
|
|
|
|
return {
|
|
isShowing,
|
|
toggle,
|
|
open,
|
|
close,
|
|
};
|
|
};
|
|
|
|
export default useToggle;
|