bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/React

React

Hooks and State Management

Use hooks to model state, effects, refs, reducers, and shared app behavior.

Lesson 1

React Hooks

Hooks allow functions to have access to state and other React features without using classes. They provide a more direct API to React concepts like props, state, context, refs, and lifecycle. What is…

2 min
Read lesson →
Lesson 2visual

React useState Hook

The React useState Hook allows us to track state in a function component. State generally refers to data or properties that need to be tracking in an application. Import useState To use the useState…

4 min
Read lesson →
Lesson 3

React useEffect Hooks

The useEffect Hook allows you to perform side effects in your components. Some examples of side effects are: fetching data, directly updating the DOM, and timers. useEffect accepts two arguments. The…

3 min
Read lesson →
Lesson 4visual

React useContext Hook

React Context React Context is a way to manage state globally. It can be used together with the useState Hook to share state between deeply nested components more easily than with useState alone. The…

3 min
Read lesson →
Lesson 5

React useRef Hook

The useRef Hook allows you to persist values between renders. It can be used to store a mutable value that does not cause a re-render when updated. It can be used to access a DOM element directly. Do…

3 min
Read lesson →
Lesson 6

React useReducer Hook

The useReducer Hook is similar to the useState Hook. It allows for custom state logic. If you find yourself keeping track of multiple pieces of state that rely on complex logic, useReducer may be use…

2 min
Read lesson →
Lesson 7

React useCallback Hook

The useCallback Hook is used to memoize a callback function. Memoizing a function means caching the result of a function so that it does not need to be recalculated. The useCallback function only re-…

3 min
Read lesson →
Lesson 8

React useMemo Hook

The React useMemo Hook returns a memoized value. Think of memoization as caching a value so that it does not need to be recalculated. The useMemo Hook only runs when one of its dependencies update. T…

3 min
Read lesson →
Lesson 9

React Custom Hooks

You can make your own Hooks! When you have components that can be used by multiple components, we can extract that component into a custom Hook. Custom Hooks start with "use". Example: useFetch. Buil…

2 min
Read lesson →