Creating a React App
To create a React app, follow these steps:
- Make sure you have Node.js and npm installed on your machine. You can verify this by running the following commands in your terminal:
SNIPPET
1node -v
2npm -v
- Install create-react-app globally by running the following command:
SNIPPET
1npm install -g create-react-app
- Create a new React app using create-react-app. For example:
SNIPPET
1create-react-app my-app
- Change into the app's directory:
SNIPPET
1cd my-app
- Start the development server:
SNIPPET
1npm start
- Open a web browser and navigate to
http://localhost:3000
to see your app running.
Once your React app is set up, you can start building your frontend components and connecting them with the backend API. Enjoy building your MERN stack project!
xxxxxxxxxx
14
// Replace the code below with your React App
import React from 'react';
function App() {
return (
<div>
<h1>Welcome to My React App!</h1>
<p>This is a sample React application.</p>
</div>
);
}
export default App;
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment