refactor(frontend):small code fix
This commit is contained in:
parent
4defd710f7
commit
0643b8b929
1 changed files with 4 additions and 4 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import { useState, useCallback } from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
export default function useToggle(defaultValue: boolean = false): [ boolean, () => void, () => void, () => void ] {
|
||||
const [ value, setValue ] = useState(defaultValue);
|
||||
const toggle = useCallback(() => setValue(d => !d), []);
|
||||
const setFalse = useCallback(() => setValue(false), []);
|
||||
const setTrue = useCallback(() => setValue(true), []);
|
||||
const toggle = () => setValue(d => !d)
|
||||
const setFalse = () => setValue(false)
|
||||
const setTrue = () => setValue(true)
|
||||
return [ value, toggle, setFalse, setTrue ];
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue