Building Up To React
Installing Node.js and NPM
When working with Node and React, you will need to use the command line. On the Mac, this is called the Terminal. On a PC, it is called the Command Prompt. Run the following commands to check your current version on node and npm. If needed, instructions on how to install or upgrade are below.
First, check to see if you have Node.js installed:
$ node -v
If this returns a version number, Node.js is installed. If the command is not found, you'll need to install Node.js from the Node.js website. Download the installer, run it, and follow the instructions.
Next, check your version of npm:
$ npm -v
Then, if you are running anything less than version 8, you will need to update npm:
Update npm on Mac
$ sudo npm update -g npm
Update npm on PC
Make sure to run the Command Prompt with administrator privileges:
$ npm update -g npm
Optionally install Yarn
Yarn is a package manager created at Facebook. It is a compatible alternative to npm. Yarn's use is not required, but you can optionally install it if you like:
$ sudo npm install -g yarn
Finally, there are some nice options for switching Node versions. This is not required, but you can optionally install one of these version mangers:
Installing the React Tools
Next, install the React developer tools:
Working with the Files
This repository links to samples hosted on various platforms, so that you can immediately begin interacting with the files. For smaller samples, we've linked to JSBins to allow you to run the sample with limited overhead. We also have links to CodeSandboxes and other repos if the samples are more in-depth.
React Resources
Finally, we have some links to resources and official documentation for the libraries that we will be using:
- React Documentation
- React Source
- React Blog
- React NPM
- webpack Documentation
- Jest Documentation
- React Router Documentation
Examples:
<a class="jsbin-embed" href="https://jsbin.com/hopomod/1/embed?js,console">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.1.8"></script>
|
Pure React
If you take the time to understand what is going on behind the scenes you will be more efficient, especially when it comes time to debug.
Samples
Page Setup
React Elements
- Rendering an Element (run it)
- Rendering an Element with Properties (run it)
- Rendering Lists (run it)
- Mapping over Elements (run it)
- Adding Keys (run it)