These steps will show you how to set up a new React application inside the workspace and repository for your DRF project.
Open the workspace for your DRF project
Open the terminal window and create a new folder called frontend in the root directory
mkdir frontend
Change directory to be inside the frontend folder with the following command
cd frontend
From inside the frontend directory, run the following command to create a new React app and install all the working dependencies used in the Moments application
npx create-react-app . --template git+https://github.com/Code-Institute-Org/cra-template-moments.git --use-npm
Enter y to confirm and then click enter
Wait for all dependencies to be installed. This installation will take some time, the terminal may appear to freeze for a few minutes. Once it does start to show activity you can ignore any deprecated warnings, these are extremely common and expected with npm installs. When the installs have been completed, your terminal will look like this
Enter the following command to remove the .git folder, .gitignore file and README.md from the frontend folder as these already exist within the root directory of your DRF project
rm -rf .git .gitignore README.md
Running this command from your workspace in the wrong working directory is dangerous. Check you are in the frontend directory by using the pwd
command.
When you have completed these steps, your file structure should look like this
From inside the frontend directory, run the following command to check that the basic React app is running
npm start
Open the browser when the preview has finished building
Stop the running application with CTRL-C in the terminal for a Windows machine, or CMD-C on a Mac
Move back to the root directory of your project with the following command
cd ..
This would be a good point to commit your changes so far.
We show you how to prepare the Django API for development.