openreplay/frontend/app/hooks/useToggle.ts
Андрей Бабушкин b822b1c067 applied eslint
2025-02-26 20:31:01 +01:00

9 lines
376 B
TypeScript

import { useState } from 'react';
export default function useToggle(defaultValue: boolean = false): [ boolean, () => void, () => void, () => void ] {
const [value, setValue] = useState(defaultValue);
const toggle = () => setValue((d) => !d);
const setFalse = () => setValue(false);
const setTrue = () => setValue(true);
return [value, toggle, setFalse, setTrue];
}