To create a React app as a complete beginner, you will need to have Node.js and npm (the Node.js package manager) installed on your computer. Once you have these prerequisites installed, follow these steps:
Open a terminal or command prompt and navigate to the directory where you want to create your React app.
Run the following command to create a new React app:
npx create-react-app my-app
This will create a new directory called "my-app" with the necessary files for a basic React app.
- Navigate into the new "my-app" directory and start the development server by running the following command:
cd my-app
npm start
This will start the development server and automatically open your default browser to http://localhost:3000/. You should see a "Welcome to React" message on the page.
To edit your React app, open the "my-app" directory in a code editor of your choice. You can make changes to the code and the development server will automatically reload the page to reflect your changes.
When you are ready to build your app for production, run the following command:
npm run build
This will create a "build" directory with optimized versions of your app's files. You can deploy these files to a web server to make your app available to the public.
Congratulations, you have created your first React app! To learn more about React and how to build more complex applications, check out the official React documentation and tutorials.
Top comments (0)