02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoPrevious Video

Setting Things Up

Setting Things Up

Welcome to the first step in Mastering React Reusable Components! This session covers essential setup tasks to prepare your development environment, ensuring a smooth journey into React development.


What You’ll Learn

In this tutorial, we will:

  • Set up Node.js and NPM for a React project.
  • Configure Webpack to streamline development.
  • Understand the basics of JSX and its role in React.

By the end, you’ll have a working development environment and a clear understanding of how to proceed with React development.


Prerequisites

To follow along, you should:

  1. Have a basic understanding of JavaScript (ES5 or later).
  2. Install Node.js and NPM on your system.
    • Verify installation:
      node -v  
      npm -v  
      
  3. Be familiar with terminal commands:
    • Linux/Mac: Use the built-in terminal.
    • Windows: Install Cygwin for a Unix-like terminal.

Installing Node.js and NPM

Node.js and NPM are essential tools for React projects. Here’s how to install them:

  1. Download the installer from Node.js Official Website.
  2. Install the latest stable version for your operating system.
  3. Confirm the installation with:
    node -v  
    npm -v  
    

What is Webpack and Why Use It?

Webpack is a module bundler that:

  • Converts modern JavaScript (like ES6 or JSX) into ES5 for browser compatibility.
  • Automates live reloading during development.

Steps to Set Up Webpack

  1. Initialize the Project:
    Open your terminal and create a new folder for your project:

    mkdir react-setup  
    cd react-setup  
    npm init -y  
    
  2. Install Webpack and Webpack Dev Server:
    Install Webpack and its development server for live reloading:

    npm install --save-dev webpack webpack-dev-server  
    
  3. Create the Configuration File:
    Create a Webpack configuration file in the project root:

    touch webpack.config.js  
    
  4. Basic Webpack Configuration:
    Edit webpack.config.js to include:

    const path = require('path');  
    
    module.exports = {  
        entry: './src/index.js',  
        output: {  
            path: path.resolve(__dirname, 'dist'),  
            filename: 'bundle.js',  
        },  
        mode: 'development',  
    };  
    

Project Folder Structure

Your project should have the following structure:

react-setup/  
├── src/  
│   └── index.js  
├── dist/  
├── webpack.config.js  
├── package.json  

Testing Your Setup

  1. Add a Sample Script:
    In src/index.js, add the following:

    console.log('React setup is complete!');  
    
  2. Run Webpack Dev Server:
    Start the development server:

    npx webpack serve  
    
  3. Check the Output:
    Open your browser and navigate to http://localhost:8080.
    Check your console for the message:

    React setup is complete!  
    

Next Steps

In the next lesson, we will:

  • Explore JSX and its integration with React.
  • Build your first React component.

Resources


This tutorial sets the stage for mastering React reusable components. Let’s move forward to creating your first JSX component!

Setting Things Up

Learn how to set up your development environment for mastering React reusable components, including Node.js, NPM, and Webpack configuration.

10:54

Configuring the Webpack Development Server

Learn to configure the Webpack Development Server for hot module replacement and automated workflows in React.

08:06

Hello JSX

Learn JSX, the JavaScript XML extension that simplifies React development. Set up JSX in Babel and explore its syntax and integration with React.

09:12

Creating a Component

Dive into React development by creating your first JSX component! In this lecture, you'll learn how to define an ES6 class, extend React components, and integrate JSX to build reusable React elements.

08:33

Developing in ES2016 Today with Babel

Learn how to configure Babel and Webpack to develop modern JavaScript applications using ES6 features. This lecture explains setting up Babel with the ES2015 preset.

09:46