DEV Community

ViGnEsH
ViGnEsH

Posted on

Hooks

May 19 2026

Hooks are a special function in React, introduced in version 16.8, that allow you to "hook into" state and lifecycle features from functional components without writing a class.

Core Built-in Hooks

React provides several built-in Hooks to handle common tasks:

  1. useState
  2. useEffect
  3. useContext
  4. useReducer
  5. useMomo & useCallback
  6. useRef
  7. use

useState

useState adds local state to a functional component, allowing it to "remember" information like user input or counter values.

**Toggle Button**

function set(){
  const [isOn, setIsOn] = useState(false);

return(
<div>
 <button onClick={() => setIsOn(!isOn)}>
                {isOn? "ON ": "OFF"}
            </button>
</div>
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)