Hack Frontend Community

useToggle Hook

Easy

Create a custom useToggle hook for managing boolean state. Requirements: ✓ Implement useToggle hook that manages a boolean value ✓ Hook should return an array: [value, toggle] ✓ toggle function should invert the current value ✓ Initial value should be configurable (default false) ✓ Demonstrate usage with practical example Acceptance Criteria: ✓ useToggle accepts initialValue (optional) and returns [value, toggle] ✓ toggle changes value from true to false and vice versa ✓ Hook can be used to control element visibility ✓ Example shows multiple use cases of the hook ✓ Clean and reusable code