Intended audience

The course has been designed for enthusiasts who have been writing JavaScript for a few years but don't necessarily have experience with React and/or the function component. For readers with less JavaScript experience, we have included a live playground so that learners can experiment with each topic in no time.

Press + to interact

If you have experience with React or even Hooks, that’s fine; this course will show you how Hooks are implemented within the function component. Moreover, a stripped-down version of the React source code pertaining to each Hook is also included in each chapter, so you will get a deeper understanding if you are an experienced React programmer.

Course structure

Here is the structure of this course.

Course structure

React essentials: function components to state management

Here is the list of technical concepts and a brief introduction to each chapter.

Introducing the Function Component

This chapter will explain what a function component is, including an explanation of its props and the basic parent/child relationship. We will then provide some tips on how to write a function component. At the end of the chapter, we will see a practical function component example, Nav.

Crafting States in Functions

This chapter will explain how to craft a special variable called state in function components. We’ll see what benefits a state can provide, including requesting a new update and listening to a value change. We’ll also see an example of applying a state to a Single Page Application (SPA). We will also take a close look at what role states play in the UI.

Hooking into React

This chapter discusses the challenges we face when creating a good state solution and how React architects provide the solution with the underlying Hook. We will then introduce Hooks, learn about their calling order, and how to avoid the conditional Hook issue in real applications.

Use State to Jumpstart Components

This chapter covers built-in Hooks, starting with the useState Hook. We will first explain how the state is used in React and then walk through the data structure and source code behind useState, and we’ll also describe common usages of dispatching states. We’ll give useState a test drive and provide two practical examples of applying useState to the Avatar and Tooltip components.

Use Effect to Handle Side Effects

This chapter introduces side effects, walks through the data structure and source code behind useEffect, and provides various scenarios in which we invoke effects. We will also demonstrate a couple of pitfalls of using useEffect and ways to avoid them. And we’ll use useEffect in two practical examples, Window Size and a Fetch API.

Press + to interact

Use Memo to Boost Performance

This chapter explains how we can run into performance degradation issues in a typical web application. Then we’ll walk through the design and source code behind useMemo and describe various ways of reusing a value conditionally. We’ll then apply the optimization technique to two common cases, clicking to search and debouncing the search.

Use Context to Cover an Area

This chapter introduces area updates and how React contexts are used to share a value to an area. Then, we’ll walk through the data structure and source code behind useContext to consume the shared value. At the end of the chapter, we’ll provide two practical examples of applying contexts to a theme and a table.

Use Ref to Hide Stuff

This chapter explains how to access a DOM element via a ref, and we’ll walk through the design and source code behind the useRef Hook. We'll also describe how to work with a persistent value without dispatching an update. Finally, we’ll apply refs to a couple of practical problems, such as clicking outside of the menu, avoiding memory leaks, setting up a mule, and locating the current value.

Use Custom Hooks to Reuse Logic

This chapter gathers all the Hooks we have learned about so far and explains how to create a custom Hook for our own needs. We'll introduce custom Hooks and then write a couple of custom Hooks step by step, including useToggle, useWindow, useAsync, useDebounced, useClickOutside, useCurrent, and useProxy.