fervor [>]CODING & CURIOSITY
FERVOR LEARNING SYSTEMTUTORIALS
← React

React / 3 MIN READ

Create React App 2

The old standby

From the original Fervor library. Examples may use older package versions.

Creating a React App with VS Code

Introduction

Welcome to FrOnt3nd Tutorials! In this tutorial, we’ll guide you through the process of creating and running a React app using Visual Studio Code (VS Code). React is a popular JavaScript library for building user interfaces, and VS Code is a powerful code editor that offers great tools for web development.

Table of Contents

Install Node.js

Before you start, make sure you have Node.js installed. If not, you can download and install it from the official website: Node.js Download

Install VS Code

If you haven’t already, download and install Visual Studio Code (VS Code) from the official website: VS Code Download

Install Required Extensions

Once you have VS Code installed, you’ll need to install some extensions to enhance your React development experience. Follow these steps:

  1. Open VS Code.
  2. Click on the Extensions icon on the left-hand side of the screen or press Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac) to open the Extensions sidebar.
  3. Search for and install the following extensions:
    • Node.js Extension Pack: Provides Node.js debugging and other tools for VS Code.
    • JavaScript (ES6) code snippets: Provides useful code snippets for writing JavaScript code.
    • Reactjs code snippets: Provides useful code snippets for writing React code.

Create a New React App

  1. Open the terminal in VS Code by clicking on “Terminal” in the top menu bar and selecting “New Terminal.”
  2. Run the following command to create a new React app named “my-app”:
    npx create-react-app my-app
    
    This command will create a new directory named “my-app” with all the necessary files and dependencies to start your React app.

Open the Project in VS Code

  1. In VS Code, click on “File” in the top menu bar and select “Open Folder.”
  2. Navigate to the “my-app” directory that was created in the previous step and click “Open.”

Run Your React App

  1. In the terminal, navigate to the “my-app” directory by running the following command:
    cd my-app
    
  2. Start a development server by running the following command:
    npm start
    
    This command will start a development server and open your React app in a new browser window.

Get Live Feedback

You can use tools like LiveReload or React Hot Loader to get live feedback on your app as you make changes to your code.

Using LiveReload

  1. Install the LiveReload browser extension.
  2. Add the following code to the bottom of your public/index.html file:
    <script src="//localhost:35729/livereload.js"></script>
    
    This enables live reloading of your app.

Using React Hot Loader

  1. Install React Hot Loader as a dependency by running the following command:
    npm install react-hot-loader
    
  2. Add the following code to your webpack.config.js file:
    module.exports = {
      // ...
      module: {
        rules: [
          // ...
          {
            test: /\.(js|jsx)$/,
            use: ["babel-loader", "react-hot-loader/webpack"],
            exclude: /node_modules/
          }
        ]
      },
      resolve: {
        alias: {
          "react-dom": "@hot-loader/react-dom"
        }
      }
    };
    

With these steps, you should be able to create, run, and get live feedback on your React app using Visual Studio Code.

Conclusion

Congratulations! You’ve successfully learned how to create and run a React app using Visual Studio Code. Keep exploring React’s features, building components, and enhancing your web development skills.

For more advanced topics and in-depth learning, refer to React’s official documentation and other resources.

Keep your curiosity going.Explore more React →
287 TUTORIALS · 22 TOPICSREADY