To set up a React JS environment, follow these steps:
-
Install Node.js and npm: React relies on Node.js and its package manager, npm, to install libraries and run development tools. Download and install from nodejs.org.
-
Install Create React App: This command-line tool by Facebook sets up a new React project with the necessary files and configurations. Run
npx create-react-app app-name
in the terminal, where “app-name” is your project’s name. -
Run the Development Server: Navigate into your project folder (
cd app-name
) and start the server withnpm start
. This opens a local server onhttp://localhost:3000
. -
Project Structure: Familiarize yourself with key folders:
- src/: Contains your application code.
- public/: Holds static files like
index.html
. - node_modules/: Contains installed dependencies.
-
Edit src Files: Start building by editing files in the
src
folder, typically beginning withApp.js
. -
Install Additional Packages (optional): Use npm or yarn to install libraries like
react-router-dom
for routing oraxios
for API requests.
This setup gives you a full React development environment with a live reloading server, making development quick and efficient.