Adventofcode 🎄: Day 7 - Hooks

codejem

Jemima M

Posted on December 7, 2023

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!!!

💖 💪 🙅 🚩
codejem
Jemima M

Posted on December 7, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related