
You will set up your first React project from scratch using Vite. Then you find that React only updates the outdated part of the page. And this is made possible by the React FiberNode.
Explore how React updates only necessary elements by examining the fiber node, alternate and original fibers, and the role of unique keys in efficient rendering.
You will figure out the file structure of React so that you can work on any React project.
We'll talk about the rules you must follow when creating your own component function.
JSX is just a syntax sugar--it's just a more convenient way of calling the createElement function.
Child elements are stored by the children array. By default, the child elements are identified by their element index. Most of the time, the element index is enough, but there are exceptions where we have to give each child element a unique key.
The element index may not always be able to differentiate the child elements.
The element index is not stable, so it cannot serve as the unique key.
In this lesson, we'll move back to JSX. Meanwhile, you will also meet a challenge.
We'll convert an object into a list.
We'll convert an array of objects into a list.
We will select a list item and pin it to the top of the list. The goal is to challenge your understanding of JSX.
We'll improve the program created in the last lesson, making it more efficient and concise.
Every React component function and custom hook must be a pure function.
Closure is a challenging topic. Understanding it benefits you for life!
The most important application of closure is to preserve data for future use.
useState provides a state and a state setter. The state setter has a must-have partner--the event handler.
React uses the batching strategy to avoid unnecessary re-renders.
Learn how React manages state with the updater and initializer functions, using callback-based updates, event handling, and useState to ensure correct increments on initial render.
In this lesson, we'll discuss the closure problem in the event handler.
The "computed" area is the area below the hooks and above the template. This is where you further process the state value, creating new values that better meet your demands.
Sometimes, there is no need to re-calculate a value. In this case, we can preserve and reuse that value using useMemo.
To make sure you have fully understood how React hooks work, we'll "fool" React by creating an error it cannot detect.
If the state is an object or array, the new state must be a new object or array.
Immer helps you create a deep copy.
Practice JSX, state management with useState or useImmer, and useMemo to render and recalculate a list built from an array of objects, then update it via a button.
We'll go back to the Pin program and recreate it using everything we have learned.
We'll create a rather complicated project to challenge your understanding of everything we have learned so far.
Learn how to create and use a child component in React, understand the parent renders first, and improve efficiency with the mammal function, useMemo, and useCallback, plus lazy and suspense.
In this lesson, we'll learn props, which is how a child component gets data from its parent.
Lift state up by sharing a single state between parent and child components, using color and message props with value and onchange handlers to sync inputs.
We'll create a custom button that can be reused in future projects.
We'll learn how to avoiding re-rendering the child component.
We'll talk about the problem caused by closure.
Learn how to use suspense and lazy loading in React to install and remove a child component on demand, improving efficiency by loading the child only when needed.
Refactor the single menu into child components so each menu manages its state, reducing rerenders. Use useState, props, and map with get own property names to render titles and content.
Understand why transitions matter in React by building a ten-item list of child components with an index prop and a toggleable render using useState. Learn rendering order and page blocking.
Learn how startTransition marks state updates as transitions to defer rerenders and keep the UI responsive, with interrupt and cancel controls showing the latest state values after restart.
Explore how the useTransition hook exposes isPending and startTransition to show a waiting notification while child components render, with an install button that disables during loading and re-enables after render.
Learn how useReducer consolidates state updates into a single reducer, using dispatched action types to manage count with increment, decrement, reset, rotate, and an initializer.
Build a to-do list in React with an item component that toggles between edit and display modes and a parent that manages add, edit, and delete.
Demonstrates building a to-do list with a reducer in React, showing useReducer syntax, state and dispatch, a draft-based reducer handling add, delete, and edit actions, and wiring event handlers.
You will learn how to use useEffect.
Do not monitor and reset the same state at the same time; otherwise, it will lead to an infinite loop.
Retrieve remote data in react using useEffect and axios.get to fetch todos and update state. Handle dynamic requests by id with a loading state and error messages to users.
Cancel ongoing requests with an abort controller before new ones to prevent race conditions in React, using a cleanup function and closure to preserve the controller for the latest response.
Dig deep:
This course digs deep--you will start by learning the "createElement" function and the virtual node. Once you know what happens under the hood, you can build real confidence and fully utilize the potential of JSX.
Keep it short:
A short course is easier to finish and more likely to be finished. This also means this course only includes the best and most effective content.
Reuse:
The examples used in this course are carefully designed so that you can learn multiple topics using just one example. This makes your life easier as you don't have to constantly learn a new project. You can make progress based on existing foundation. Meanwhile, this also gives you the perfect opportunity to review what you have learned.
Improve:
We'll create a "bad" program first and then show you why it's bad and how to improve it.
Understand the problem first:
If you don't understand what the problem is, then the solution to that problem can be very difficult to learn. For example, before we learn transition, we'll first learn why transition is needed. Then we'll learn "startTranstion." In the end, we'll learn "useTransition." This helps keep the learning curve smooth.
Closure:
Closure is the most important JavaScript topic and also the most challenging one. React provides the perfect opportunity to help you understand closure for good!
Closure is a double-edged sword. On one hand, it helps us preserve data for future use; on the other hand, closure also means outdated data may be used. useEffect is the perfect example to learn and understand the two sides of closure.
"Edgy" Situations:
This course has included lots of "edgy" situations that require special treatment. For example, if the state is an array, then useMemo may not work properly. The solution is to add an extra state to control the list order. These edgy situations are very useful in real-life projects and can also help deepen your understanding of React.
Visual aids:
This course has added lots of animations to show you how React works. These animations will make difficult concepts easier to understand.