Create new react app
To create a new React app, you can use the create-react-app
command-line tool. Here are the steps:
Step 1: Install create-react-app
Open your terminal and run the following command:
npm install -g create-react-app
This will install create-react-app
globally on your system.
Step 2: Create a new React app
Once installed, run the following command to create a new React app:
npx create-react-app my-app
Replace my-app
with the name of your app.
Step 3: Navigate to the app directory
After creating the app, navigate to the directory using the following command:
cd my-app
Step 4: Start the app
To start the app, run the following command:
npm start
This will start the development server and open your app in your default web browser.
Step 5: Explore the app
You can now explore the app by navigating to the src
directory, which contains the React code. You can also modify the code and see the changes reflected in the browser.
That's it! You now have a brand new React app up and running.
Here's a breakdown of the files and directories created by create-react-app
:
public
: This directory contains static assets that are served by the development server.src
: This directory contains the React code, including components, containers, and utility files.node_modules
: This directory contains the dependencies installed bynpm
.package.json
: This file contains metadata about the app, including dependencies and scripts.