In this article, we’ll walk you through setting up a ReactJS project from scratch. We’ll cover creating a new project, installing dependencies, and writing your first React component.
Step 1: Create a New Project
Open your terminal or command prompt and run the following command:
npx create-react-app my-react-app
Replace my-react-app
with your desired project name
Step 2: Install Dependencies
Once the project is created, navigate to the project directory and install the dependencies:
cd my-react-app
npm install
Step 3: Write Your First React Component
Open the src/App.js
file and replace the code with the following:
Jsx
import React from ‘react’;
function App() {
return <h1>Hello, World!</h1>;
}
export default App;
Step 4: Start the Development Server
Run the following command to start the development server:
npm start
Open your web browser and navigate to http://localhost:3000
to see your first React component in action!
You Should learn Introduction to ReactJS: A Beginner’s Guide here
Conclusion:
That’s it! You’ve successfully set up a ReactJS project and written your first React component.