Practical 1: Setting Up the Environment in React
Objective:
To set up a React development environment using Node.js and Create React App, and create a
basic React project displaying "Hello, React!".
Steps:
1. Install Node.js and npm:
- Download and install Node.js from https://nodejs.org/
- Verify installation:
node -v
npm -v
2. Create a React App:
Open your terminal and run:
npx create-react-app hello-react
cd hello-react
npm start
This will start a development server and open the default React app in your browser.
Code (src/App.js):
import React from 'react';
function App() {
return (
<div style={{ textAlign: 'center', marginTop: '50px' }}>
<h1>Hello, React!</h1>
<p>Welcome to your first React application setup.</p>
</div>
);
export default App;
Output:
When you run `npm start`, your browser should display:
Hello, React!
Welcome to your first React application setup.