The Complete React Tutorial for 2021 Learn Major React Concepts by Building a Project

This course contains 177 interactive scrims spread across 4 modules. Notice how each button “remembers” its own count state and doesn’t affect other buttons. Please plan to get enough practice as you start walking through the path. My DMs are open on Twitter if you want to discuss further.

  • This keeps the child components in sync with each other and with their parent.
  • Calling useState(), you will get back a new state variable, and a function that we can call to alter its value.
  • Anything you’ve already learned will still be useful, for example when dealing with legacy code.
  • It promotes several good development practices, including code reusability and component-driven development.
  • If the square is already filled, you will return in the handleClick function early—before it tries to update the board state.
  • It does not matter whether you define calculateWinner before or after the Board.

We don’t have to pass it an initial value, but we can give it a default value if we needed to. In this case, we want a reference to this input element with the name of “addTodo.” We’ll call our state variable todos and the setter to manage our state setTodos. To take care of submitting our form, we need to start working with events in React.

🟢 Anti-Patterns in React

Try the first 67 lessons, challenges, projects (first 9 chapters) & flashcards for free. No time limit.The remaining chapters require a PRO account. That’s why we’ve developed a separate flashcards app where you can reinforce the new concepts that you learned using spaced repetition. Understand how React works not just how to build with React.

So you can immediately start the app by going into the newly created application folder and running npm start. Create-react-app is a command line application, aimed at getting you up to speed with React in no time. To start with, I highly recommend one approach, and that’s using the officially recommended tool called create-react-app. The goal of this handbook is to provide a starter guide to learning React. It allows us within handleAddTodo to use the property inputRef.current, which contains the input element itself.

🟣 Reconciliation Process in React

This makes them reusable wherever we need them across our app, it better organizes our code, and it makes it easier to understand our projects. Right now we’re looking at our app component, which is the only component that’s being displayed in our application. If we look at our file explorer on the left, we’ll see app is being imported and rendered here within this index.js file. React is used for frontend web apps to detect user input, fetch data, and update the user interface with data. Often, you’ll want your component to “remember” some information and display it.

I have also specified some resources to help you learn at an incredible pace. You are in an unknown city, and you have to travel from one place to another. What you need most is a map or guide to help with your travels.

🟣 Form Handling in React

This means we can’t use this reserved word as we want. It serves a specific purpose (defining JavaScript classes) and the React creators had to choose a different name for it. In particular, in a React component you can import other React components, and you can embed them and display them.

Now if a user double clicks a list item, only then do we toggle it done. Once again, we need to connect it to a function to handle our click event. We’re going to call this handleToggleTodo and create it within our TodoList component. In this case, our function that we use to handle the event doesn’t have to receive any event data. This function will handle updating our todo’s state. Additionally, React hooks are called up at the very top of function components.


Using this.setState, we have changed our data value when the user types. A component is a plain JavaScript function which takes a prop as an argument and returns a React element (see above example). It has no lifecycle methods (like React Lessons componentDidMount method etc. which you might have read during your research on React tutorials). If you look at the second example, React.createElement is used for creating a react element to represent the react component.

React Lessons

Leave a Reply