React (JavaScript framework)

Table of contents

Child pages

Related pages

Pros and Cons


Courses / Tutorials

React 16 - The Complete Guide (incl. React Router 4 & Redux)

Section 1: Getting Started

1. Introduction

  • React is an amazing library for creating highly-reactive and super-fast JavaScript-driven web applications.
  • React is the most popular JavaScript library you can learn these days.
  • You'll learn what React is about, how it works, (he goes on).
  • We will build a React application throughout this course.

2. What is React?

  • What is React? Quoting the official page, "It's a JavaScript library for building user interfaces."
  • React is all about using components for building user interfaces.
  • He gives an example of a website and how it could be broken into components.
  • By breaking the website into components, we can have the code better organized. We can also easily re-use the code.
  • Components can be thought of as custom HTML elements.

3. Real-World SPAs & React Web Apps

  • Let's look at some components in action. We'll go to reactjs.org, which is built with React.
    • The header is a component, and within it are single navigation components, there's a call-to-action component, there's an info section component, there are code-snippet components.
    • All of these are reusable building blocks.
  • Another good example is Udemy: it has a header, a search result summary / filter component, reused list-item components.
  • Again, this approach makes it easier to develop, maintain, and update the website.

4. Adding the Right React Version to Codepen

5. Writing our First React Code

  • CodePen.io is a like an online playground for writing code.
  • Click Create → New Pen.
  • Let's create a simple demo to see how we'd create something with normal HTML and JavaScript, and how we could add React to make it easier.
  • He creates "person card" divs that have the person's name and age.
  • We can see one limitation: we're always re-using the same HTML code.
  • He then adds React and React DOM.
    • Click the gear icon next to the word "JavaScript".
    • React is focused on the logic of components, while React DOM handles the rendering.
    • In the JavaScript preprocessor option, choose Babel so that we can use ES6 syntax.
  • In its basic form, a React component is just a function.
    • The name needs to start with a capital letter.
    • React uses a special syntax called "JSX" that lets us put HTML where the "return" statement is.
  • He puts a new div in the HTML that has an id of "p1".
  • He then adds "ReactDOM.render();" to his JavaScript section, which is what takes our function and renders it to the page.
    • He passes his function in a special syntax: "<Person />", and passes in a second argument which has the selector it should look for in the HTML.
    • The finished code looks like this: ReactDOM.render(<Person />, document.querySelector('#p1'));
  • He loses the styling at first because "class" is a reserved word in JavaScript, so he needs to change "class" to "className" in his JSX code.
  • Another issue is that his "inline-block" styling isn't working (his new React person card and his old HTML person card are not inline with each other), because we're effectively wrapping the div within the new <Person /> custom element.
  • Within your React function, you'll have access to an argument (which is known as "props" but can be named whatever you want) which contains all of the key-value attribute pairs within the <Person /> tag that shows up in the .render() function.
  • To access the props variable within your JSX code, use a single pair of curly braces, so  {props.name}, {props.age}, where those values are passed in via the .render() call. So, for example, ReactDOM.render(<Person name="Max" age=28 />, ...)
  • He then shows how to have a single .render() function by creating a single "app" div, and then having an "app" variable in his JavaScript code that contains the JSX code.
    • NW: So this is very similar to Vue.js

6. Why Should we Choose React?

  • UI state becomes difficult to manage with vanilla JavaScript.
  • It allows us to focus on our "business logic". The framework creators can be trusted to write reliable code.
  • It has a huge ecosystem, an active community, and high performance.

7. React Alternatives

  • Angular and Vue.js are the most popular alternatives.
    • Ember and Backbone are also alternatives but are not as popular.
  • All three (React, Angular, Vue) are great for building large dynamic UIs.
  • jQuery is not much of an alternative for these kinds of reactive apps. It focuses on traversing the DOM and targeting elements in the DOM.

8. Understanding Single Page Applications and Multi Page Applications

  • There are two kinds of applications we can build: a single page application and a multi-page application.
  • In a single-page application, the user gets a single HTML file. After that, everything is managed with JavaScript.
  • In a multi-page application, we are sent multiple HTML pages as we navigate through the website.
  • The SPA approach is more popular nowadays because it can make things seem faster, and even if the user needs to wait for data, you can show a spinner rather than just seeing a blank screen while the new page loads.
  • In an SPA, you typically have only one ReactDOM.render() call. In a multi-page approach you would make one call for each isolated React widget.

9. Course Outline

  • His summary isn't much more than what you can infer from the reading the names of the sections.

10. How to get the Most out of This Course

  • Code along
  • Check his source code
  • Ask and answer in Q&A
  • Practice

Section 2: Refreshing Next Generation JavaScript (Optional)

Section 3: Understanding the Base Features & Syntax

Section 4: Working with Lists and Conditional

Section 5: Styling React Components & Elements

Section 6: Debugging React Apps

Section 7: Diving Deeper into Components & React Internals

Section 8: A Real App: The Burger Builder (Basic Version)

Section 9: Reaching out to the Web (Http/Ajax)

Section 10: Burger Builder Project: Accessing a Server

Section 11: Multi-Page-Feeling in a Single-Page-App: Routing

Section 12: Adding Routing to our Burger Project

Section 13: Forms and Form Validation

Section 14: Redux

Section 15: Adding Redux to our Project

Section 16: Redux Advanced

Section 17: Redux Advanced: Burger Project

Section 18: Adding Authentication to our Burger Project

Section 19: Improving our Burger Project

Section 20: Testing

Section 21: Deploying the App to the Web

Section 22: Bonus: Working with Webpack

Section 23: Bonus: Next.js

Section 24: Bonus: Animations in React Apps

Section 25: Bonus: A Brief Introduction to Redux Saga

Section 26: Bonus: Building the Burger CSS

Section 27: Next Steps and Course Roundup