Repository navigation
1 intro
- What's so great about React?
- Comparisons with other systems?
-
First we need to install Homebrew, it is a package manager that we use to install other programs. Go to the Homebrew site https://brew.sh and copy the line of code from the Install Homebrew section.
-
Open a Terminal window, paste the line you just copied and press
Return. Follow the prompts to continue the installation. -
Then install Node by running (copy, paste, press Return) this in the terminal:
brew install node- Check that node and npm installed OK by running these commands
node -v
npm -v
- Set yourself as an owner of ~/.npm directory and /usr/local/lib/node_modules directory:
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
anyone?
We can use an npm package called create-react-app to create a basic React project. Create-react-app will make a folder with a name we give it, and download Javascript packages (including the React ones) and some template files into that folder. We will edit the template files to build our app.
Some housekeeping first, think about where you want to keep your projects on your computer. One approach is to put a "sandbox" folder somewhere - your Desktop, or user home folder. Here's how to make a sandbox folder in your home folder using the command line, and navigate there.
mkdir ~/sandbox
cd ~/sandbox
Now we are in the sandbox folder, create the app:
npx create-react-app my-app
Once it is done, change into the project folder and start the app.
cd my-app
yarn start
This launches a hot reloading server and shows the app in the browser. Hot reloading means we can make changes to the code and the browser will update automatically without us needing to reload.