DEV Community

Cover image for Adventofcode 🎄: Day 7 - Hooks
Jemima M
Jemima M

Posted on

Adventofcode 🎄: Day 7 - Hooks

In React, a hook is a special function that allows you to use state and other React features in functional components. Hooks were introduced to enable functional components to manage state and side effects, which were previously exclusive to class components.

The most commonly used React hook is the 'useState' hook, which allows functional components to have local state.

'useState'

This hook allows you to add state to functional components. It returns an array with two elements: the current state value and a function that lets you update it.

'useEffect'

This hook enables you to perform side effects in your functional components. It can be used for tasks such as data fetching, subscriptions, or manually changing the DOM.

These are just a couple of React hooks, there are others such as 'useContext', 'useReducer', and 'useCallback'.

I hope that this short description on React hooks has helped, in the meantime....KEEP CODING!!!

Top comments (0)