yarn add react-ready-hooks
-
useToggle
Hook for handling boolean state. -
useTimeout
Hook for executing function after some delay -
useUpdateEffect
Hook for executing function only when their dependencies gets change
const [value, toggleValue] = useToggle(false);
Methods:
-
toggleValue()
- allow you to toggle state and you can also pass boolean value to set state.
Properties:
-
value
- the current state
const { clear, reset } = useTimeout(() => {}, 1000);
This hook accept two parameter -> function to be execute and delay in milli second.
Methods:
-
clear()
- allow you to clear timeout. -
reset()
- allow you to reset timeout.
const [count, setCount] = useState(100);
useUpdateEffect(() => alert(count), [count]);
This hook accept two parameter -> function to be execute and dependencies array.