React needs Node.js runtime. Download the LTS version from nodejs.org.
node -v npm -v
Example output: v20.10.0, 10.2.3
Recommended extensions for productivity:
Open your Terminal or Command Prompt and run:
npx create-react-app businesspro-react
| Command | Purpose |
|---|---|
| npx | Executes packages without global install |
| create-react-app | Official React project starter template |
| businesspro-react | Your project folder name |
cd businesspro-react npm start
Browser will open: http://localhost:3000
React uses a library to handle multiple pages without reloading.
npm install react-router-dom
import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Home from "./Home";
import Manage from "./Manage";
import Data from "./Data";
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/manage" element={<Manage />} />
<Route path="/data" element={<Data />} />
</Routes>
</BrowserRouter>
);
}
export default App;
Replaces index.html. Includes useEffect for lifecycle management.
import React, { useEffect } from "react";
import { Link } from "react-router-dom";
function Home() {
useEffect(() => {
alert("Welcome to BusinessPro Solutions!");
}, []);
return (
<div>
<header>
<h1>BusinessPro Solutions</h1>
<nav>
<Link to="/">Home</Link>
<Link to="/manage">Add/Edit Service</Link>
<Link to="/data">Service List</Link>
</nav>
</header>
<section id="hero">
<h2>Welcome to the Future</h2>
<img src="/assets/giphy-1.gif" width="100%" />
</section>
<footer>© {new Date().getFullYear()} BusinessPro</footer>
</div>
);
}
export default Home;
Replaces manage.html. Uses useState to control form inputs.
import React, { useState } from "react";
import { Link } from "react-router-dom";
function Manage() {
const [name, setName] = useState("");
const [desc, setDesc] = useState("");
function handleSubmit(e) {
e.preventDefault();
if (name.trim() === "" || desc.trim() === "") {
alert("Please fill all required fields");
return;
}
alert("Service Saved Successfully!");
}
return (
<div>
<Link to="/">Back to Home</Link>
<h2>Add/Edit Service</h2>
<form onSubmit={handleSubmit}>
<input value={name} onChange={(e) => setName(e.target.value)} />
<textarea value={desc} onChange={(e) => setDesc(e.target.value)} />
<button type="submit">Save</button>
</form>
</div>
);
}
export default Manage;
Replaces data.html. Displays the service catalog table.
function Data() {
return (
<div>
<h2>Service Catalog</h2>
<table border="1">
<thead>
<tr>
<th>ID</th><th>Name</th><th>Status</th>
</tr>
</thead>
<tbody>
<tr><td>001</td><td>Web Dev</td><td>Active</td></tr>
</tbody>
</table>
</div>
);
}
export default Data;
| HTML Project | React Project |
|---|---|
| Multiple .html files | Components (.js) |
| <a> tags (Reloads page) | <Link> (No reload) |
| Direct DOM JS | React Hooks (useState, useEffect) |
| Static rendering | SPA (Single Page Application) |