ReactJS-The Beginner Master Class
  • React In the Beginning
    • Lesson 1 - Demo: Build a Simple React App - Fast
    • Lesson 2 - HTML Review
    • Lesson 3 - CSS Review
    • Lesson 4 - Modern JavaScript (JSX) Patterns
    • Lesson 5 - Set up Dev Environment
    • Hands-on Practice
  • React Fundamentals
    • Lesson 1 - Understanding Old vs New Way of Building Web Apps - SPAs
    • Lesson 2 - Motivation for Using React as the Solution to Vanilla JS
    • Lesson 3 - What is ReactJS - How it Works
    • React Code Along from Scratch
    • Lesson 4 - Create and Run a React Project with Vite - Full Overview
    • Lesson 5 - Create Hook by State Management in React
    • Lesson 6 - React Project File and Folder Walkthrough
    • Lesson 7 - JSX and How React Treats the DOM & JSX Compilation(by Babeljs) - Overview
    • Lesson 8 - Understanding the Main Files - App.jsx and main.jsx
    • Lesson 9 - Props and One-Way Data Flow - Overview
    • Lesson 10 - Google Bookshelf App - Ver 1.0
    • Hands-on Practice I
    • Hands-on Practice II
  • React State and Styling
    • Lesson 1 - Pulling Book Data from a Different Data File
    • Lesson 2 - Overview of How State Works in React
    • Lesson 3 - RandomQuote App
    • Lesson 4 - Lifting State Up - React Pattern Overview
    • Hands-On - Simple Counter
  • Forms and Interactivity - Grocery List App
    • Lesson 1 - Setup a Simple Form and Input
    • Lesson 2 - Build Form Profile App Using Multi-input Form Data
    • Hands-on : Build a Grocery List App
  • Connecting to the Backend - Consuming APIs - UseEffect Hook
    • Lesson 1 - Connecting to the Back End - Understanding Side Effects, Hooks and useEffect - Overview
    • Lesson 2 - Fetching Data from the Backend the Right Way with useEffect Hook
    • Lesson 3 - Setting Up Loading State
    • Hands-on :Use Dependency Array and Adding Values that Control Side Effects
  • Solo Project 1
  • RESTful APIs :Build a BookSearch App -Ver 2.0
    • Lesson 1: Build and test RESTful APIs with Postman
    • Lesson 2 - BookShelf App Structure
    • Lesson 3 - Create NavBar.jsx Component
    • Lesson 4 - Create Footer Component
    • Lesson 5 - Create BookList.jsx Component
    • Lesson 6 - Create BookCard.jsx Component
    • Lesson 7 - Creating Custom Hooks - useBooks and api-client
    • Lesson 8 - Controlling Network Activities in React with AbortController
    • Lesson 9 - Show Book Details in a Modal - Working
    • Lesson 10 - Bookshelf App Summary
  • Multi-Page Applications (MPAs)
    • Build a Multi-Page React Application
    • Multi-Page React Application
    • Hands-on Practice
  • Backend Frameworks-NEXT.JS
    • Migrating from React to Next.js
    • Lesson 1: Key Concepts of NodeJS and Express for Backend Web Development
    • Lesson 2: How to set up a new Next.js project
    • Lesson 3: How to create Layouts and Pages
    • Hands-on Practice 1
    • Hands on Practice 2
      • New Project & Folder Structure
      • File-Based Routing
      • Server vs Client Components & Router Hooks
      • Start On The Navbar
      • Navbar Links, Dropdowns & React Icons
      • Active Links & Conditional Rendering
      • Homepage Components
      • Properties Page
      • Property Card Dynamic Data
      • Home Property Listings
      • Custom Not Found & Loading Pages
  • Git and GitHubs
    • Git Installation
    • Git Commands
    • GitHub Repository
    • Hands-on Practice
  • Database in Application
    • React Supabase CRUD
    • Hands-on: Note Taking App
  • NoSQL Database
    • Installing MongoDB Community Edition
    • System Env Path Setting
    • How to use MongoDB Shell
    • How to Connect and Use Mongosh in VS Code via MongoDB Extension
    • MongoDB Guide
  • Solo Project 2
  • Deployment and Web Hosting
    • Lesson 1. React+Vite+TS+Shadcn Project
    • Lesson 2. Deploying a React Vite App to Vercel from Vercel CLI
    • Lesson 3 Connecting to GitHub Repo and Automate Deployment
  • Solo Project 3
  • Final Term Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 2 Team Project
    • Level 2 Team Project
    • Level 3 Team Project
    • Level 3 Team Project
Powered by GitBook
On this page
  • Setup Environment
  • Visual Studio Code
  • NodeJS
  • Git and Git-Bash Terminal on Windows
  • Generation of Disposable Temp Email
  • Sign up and Sign in for Supabase
  • Sign up and Sign In to Postman
  • Sign up and Sign In to GitHub
  • Ground Up from the Base
  • Vite + React Project Creation
  • Step 1: Set Up the React App
  • Code base for react-fun-facts-yourname project
  • Understanding the Difference between export default and export with Named Exports in JavaScript
  • 1. export default (Default Export)
  • 2. Named Exports
  • Key Differences Summarized
  • Export to Sheets
  1. React In the Beginning

Lesson 5 - Set up Dev Environment

PreviousLesson 4 - Modern JavaScript (JSX) PatternsNextHands-on Practice

Last updated 4 months ago

Setup Environment

Visual Studio Code

  1. download Visual Studio Code for your platform (Windows, Mac, Linux) and install

  1. start VS Code

  2. Press Ctrl+Alt+I or select Use AI Features with GitHub Copilot for Free... from the Copilot menu in the title bar

  3. Select Sign in to Use Copilot for Free to sign in to your GitHub account and sign up for Copilot Free

  4. Install VSC extensions :

    1. Prettier - Code formatter

    2. Theme oh lucy

    3. ES7+ React/Redux/React-Native snip

At Bash/Windows PowerShell terminal,

$code -v

  1. ES7+ React/Redux/React-Native snippets

  2. Prettier - Code formatter

  3. ESLint

  4. HTML Boilerplate

  5. Live Server

NodeJS

Download the package and install latest Node.js

Update nodeJS Using the Node.js Installer (Windows and macOS)

use below npm command to upgrade npm to latest

$ npm install -g npm@latest
 
// Verify latest Installation update
$ npm -v

Download and install NVM for Windows/Mac/Linux

Click on the nvm-setup.exe asset which is the installation file for the tool:

Open the file that you have downloaded, and complete the installation wizard.

At Bash/Windows PowerShell terminal,

$node -v

$node --help

$npm -v

$nvm -v

$nvm --help

Git and Git-Bash Terminal on Windows

How To Install Git Bash On Windows

  • Go to the website: Navigate to the official Git for Windows website (git-scm.com).

  • Download the installer: Click "Download" to get the latest version of the Git installer for Windows.

  • Run the installer: Open the downloaded executable file (Git-2.47.1.2-64-bit.exe).

  • Follow the prompts:

    • Accept the license agreement.

    • Choose the default installation directory.

    • Important: During the installation options, make sure to select "Add Git Bash to the PATH" or a similar option to access Git Bash from your command prompt, ensuring to select the "Git Bash" option during the installation process.

  • Finish installation: Click "Install" and then "Finish" to complete the process.

// to verify Git was installed.
$ git version 

Generation of Disposable Temp Email

Sign up and Sign in for Supabase

Two options for sign up ::

  • Continue with GitHub account or

  • Use your email account and check your email for confirmation.

  • After finishing sign up, now you can sign in with your credentials

Sign up and Sign In to Postman

Enter your email address for Sign Up for free. Check your email for confirmation.

After finishing sign up, now you can sign in with your credentials either by Sign In with Google or email.

Sign up and Sign In to GitHub

Use your email to create GitHub free account

  • Email:

  • Password:

  • Username:Aklebek

Verify your account with visual or audio puzzle

Confirm your email address and enter code. You are all set and good to go.

Ground Up from the Base

Vite + React Project Creation

Step 1: Set Up the React App

    1. check whether you already installed a right version of node.js

// Bash
node -v
npm -v
  1. Open Bash/PowerShell terminal and create your working directory, ie. "react-sandbox". Change the directory to "react-sandbox" and install vite latest version.

S npm create vite@latest

Then follow the prompts!

  • Project name:react-fun-facts-yourname

  • Select a framework: > React

  • Select a variant: > JavaScript

  1. Change the directory to "react-fun-facts-yourname". And then install and run.

  • Install any necessary dependencies (optional): While this basic app doesn't require additional libraries, you can install styling libraries like Bootstrap if needed:

// cd react-fun-facts-yourname
npm install
npm install bootstrap
npm run dev
  1. Click : http://localhost:5173

  2. Try our codebase example - static react app

Code base for react-fun-facts-yourname project

// index.html

<html>

   <head>
	<link rel="stylesheet" href="/index.css">
   </head>

   <body>
	<div id="????"></div>
	<script src="/?????.jsx" type="module"></script>
   </body>

</html>
```
// main.jsx

import { ????? } from "react-dom/client"
const root = createRoot(document.getElementById("????"))

root.????(
    <main>
        <img src="./react-logo.png" width="????" alt="React logo" />
        <h1>?????????!</h1>
        <ul>
            <li>Was first release in 2013</li>
            <li>Was originally created by Jordan Walke</li>
            <li>Has well over 200K stars on GitHub</li>
            <li>?????</li>
            <li>Powers thousands of enterprise apps, including mobile apps</li>
        </ul>
    </main>
)
// index.html
body {
    padding: 20px;
    font-family: Arial, Helvetica, sans-serif;
    background: #27292c;
    color: white;
}

h1 {
    margin-top: 30px;
}
// Main.jsx - Updated

import { createRoot } from "react-dom/client"
const root = createRoot(document.getElementById("root"))

root.render(
    <??????? />
)

function ??????() {
    return (
        <main>
            <img src="./react-logo.png" width="40px" alt="React logo" />
            <h1>Fun facts about React!</h1>
            <ul>
                <li>Was first release in 2013</li>
                <li>Was originally created by Jordan Walke</li>
                <li>Has well over 200K stars on GitHub</li>
                <li>Is maintained by Meta</li>
                <li>Powers thousands of enterprise apps, including mobile apps</li>
            </ul>
        </main>
    )
}

Understanding the Difference between export default and export with Named Exports in JavaScript

In JavaScript modules, export statements are used to make functions, objects, or primitive values available to other modules. There are two main ways to export: export default and named exports. Here's a breakdown of their differences:

When creating JavaScript modules, there are two common ways to export code from a file: using export default and using export with named exports.

1. export default (Default Export)

  • One per module: You can have only one default export per module.

  • Import with any name: When importing a default export, you can use any name you want.

  • Common use case: Typically used for exporting the primary or main functionality of a module.

Syntax:

  • Exporting:

    JavaScript(JSX)

    // Method 1: Exporting a value directly
    export default function myFunction() {
      // ...
    }
    
    // Method 2: Exporting a variable
    const myVariable = "Hello";
    export default myVariable;
    
    // Method 3: Exporting an object
    export default {
        name: "John Doe",
        age: 30
    }
  • Importing:

    JavaScript(JSX)

    import anyNameYouWant from './myModule'; // No curly braces
    
    anyNameYouWant(); // If it was a function
    console.log(anyNameYouWant); // If it was a variable or object

Example:

JavaScript(JSX)

// myModule.js
export default function greet(name) {
  return `Hello, ${name}!`;
}

// app.js
import greeting from './myModule'; // Renamed to 'greeting'

console.log(greeting("Alice")); // Output: Hello, Alice!

2. Named Exports

  • Multiple per module: You can have multiple named exports in a single module.

  • Import with the same name (or alias): When importing named exports, you must use the same name as the export, or use an alias with the as keyword.

  • Common use case: Used for exporting multiple functions, objects, or values that are related but not necessarily the primary functionality.

Syntax:

  • Exporting:

    JavaScript(JSX)

    //myModule.jsx
    // Method 1: Exporting declarations
    export function myFunction1() { /* ... */ }
    export const myVariable1 = 10;
    export class MyClass { /* ... */ }
    
    // Method 2: Exporting existing bindings
    function myFunction2() { /* ... */ }
    const myVariable2 = "World";
    export { myFunction2, myVariable2 };
    
    // Method 3: Renaming during export
    function myFunction3() {}
    export { myFunction3 as myRenamedFunction };
  • Importing:

    JavaScript(JSX)

    import { myFunction1, myVariable1 } from './myModule'; // Curly braces are required
    import { myFunction2 as func2 } from './myModule'; // Importing with alias
    
    myFunction1();
    console.log(myVariable1);
    func2();

Example:

JavaScript(JSX)

// utils.js
export function add(a, b) {
  return a + b;
}

export function subtract(a, b) {
  return a - b;
}

// app.js
import { add, subtract as minus } from './utils';

console.log(add(5, 3));    // Output: 8
console.log(minus(10, 4)); // Output: 6

Key Differences Summarized

Feature

export default

Named Exports

Number per module

One

Multiple

Import name

Any name

Same name (or alias)

Syntax (import)

import anyName from 'module';

import { name1, name2 } from 'module';

Use Case

Main functionality of a module

Multiple related functions, objects, or values

Export to Sheets

Which to Use?

  • Use export default when you have a single primary export from a module, like a class or a function that represents the main purpose of the module.

  • Use named exports when you have multiple related exports from a module. This improves code clarity and allows for more granular imports.

By understanding these differences, you can effectively structure your JavaScript modules and improve code organization.

To install Git Bash on Windows, go to the official Git for Windows website (), download the latest version, run the executable file, and follow the on-screen instructions, ensuring to select the "Git Bash" option during the installation process; essentially, you're installing the full Git package which includes Git Bash as a component.

Visit site to generate a temporary email for test.

Go to site.

Go to site

Go to site

go to vite.dev site and click get started ().

Vite requires version 18+ or 20+.

https://git-scm.com/downloads/win
https://temp-mail.org/en/
https://supabase.com/dashboard/sign-up
https://www.postman.com/
https://github.com/signup
https://vite.dev/guide/
Node.js
https://code.visualstudio.com/code.visualstudio.com
Node.jsNode.js
GitHub - coreybutler/nvm-windows: A node.js version management utility for Windows. Ironically written in Go.GitHub
Logo
Logo