A simple hook to toggle a boolean value between true and false. Useful for toggling states like modals, dropdowns, or toggling any component's visibility.
Parameters:
initialValue: boolean – The initial value to toggle.
Returns:
value: boolean – The current boolean value.
toggle: () => void – A function to toggle the value between true and false.
const [isToggled, toggle] = useToggle(false);
Goal: Implement a hook that toggles a boolean value and returns the state and toggle function.
A simple hook to toggle a boolean value between true and false. Useful for toggling states like modals, dropdowns, or toggling any component's visibility.
Parameters:
Returns:
Goal: Implement a hook that toggles a boolean value and returns the state and toggle function.