How to Install React: Setting up a React project can be done using different methods, with create-react-app being the most popular choice for beginners due to its simplicity.
- Using : create-react-app
npx create-react-app my-app
cd my-app
npm start
Manually Setting Up React: If you prefer a custom setup:
- Install React and ReactDOM:
npm install react react-dom
- Create an HTML file and link the bundled JavaScript from a build tool like Webpack.
Example of a Basic React Setup:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My React App</title>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>