fullstack_webdev

Code and notes from Full stack web developer path, LinkedIn Learning.

View on GitHub
  1. ReactJS Essential Training

0. Introduction


1. What is React?

01_01 What is React?

01_02 Setting up Chrome Tools for React


2. Intro to React Elements

02_01 Installing Create React App

02_02 Generating a Project

02_03 Creating React Elements

02_04 Refactoring Elements with JSX

// without JSX

ReactDom.render(
  React.createElement(
    "ul",
    null,
    React.createElement("li", null, "Monday"),
    React.createElement("li", null, "Tuesday"),
    React.createElement("li", null, "Wednesday")
  ),
  document.getElementById("root")
);

// with JSX
ReactDom.render(
  <ul>
    <li>Monday</li>
    <li>Tuesday</li>
    <li>Wednesday</li>
  </ul>,
  document.getElementById("root")
);

03. React Components

03_01 Creating a react components

03_02 Adding Component Properties

03_03 Working With Lists

03_04 Adding keys to list items

function Main(props) {
  const dishes = props.dishes;
  const dishItems = dishes.map((dish, index) => <li key={index}>{dish}</li>);
  return (
    <section>
      <p>
        Best fast food place in town serving the most {props.adjective} food.
      </p>
      <ul style=>{dishItems}</ul>
    </section>
  );
}

03_05 Displaying Images with React

function Main(props) {
  return (
    <section>
      <p>We serve the most {props.adjective} food in the town.</p>
      <img src={restaurant} height="250" alt="restaurant snap" />
      <ul style=>
        {props.dishes.map((dish) => (
          <li key={dish.id}>{dish.title}</li>
        ))}
      </ul>
    </section>
  );
}

03_06 Using Fragments

Quick Revision

import App from "./App";
ReactDOM.render(<App />, document, getElementById("root"));

To use the App function, you must import the function, and then call it from ReactDOM.render.

function App() {
  return (
    <div classname="App">
      <Header />
      <h2>Main</h2>
      <div>); }

Enclosing the Header function within angle brackets will cause the contents of the function to be rendered.

{
  props.dishes.map((dish) => <li>{dish}</li>);
}

The correct way to print a list is to call the map function on the list dishes that is attached to the props function parameter.

The correct way to pass in a parameter is to provide a property name which equals the content we want to send. In this case, the content is the output of a JavaScript function.

function Header(props) {
  console.log(props);
  return (
    <header>
      <h1>{props.name}'s Kitchen</h1>
    </header>
  );
}

04 React State in the component tree

04_01 Conditional Rendering

04_02 Destructuring Arrays and Object

const [, , light] = ["boots", "tent", "headlamp"];
console.log(light); // Will print headlamp to console.

04_03 Understand the useState Hook

04_04 Working with useEffect

04_05 Incorporating useReducer


05 Asynchronous React

05_01 Fetching Data with Hooks

05_02 Displaying Data from an API

05_03 Handling loading states


06 React Testing

06_01 Using Create React App as a testing platform

06_02 Testing small functions with Jest

06_03 React Testing Library

06_04 Testing Hooks with React Testing Library


07 React Router

07_01 Installing React Router 6

07_02 Configuring the router


Resources