react_setup
Setup
Yarn
Yarn is a superset of NPM that solves many problems that NPM has, NPM stands for Node Package Manage , It keeps track of all the packages and their versions and allows the developer to easily update or remove these dependencies. All of these external dependencies are being stored inside a file called called package.json. when you have a node project, as package.json has all dependencies and version, you can easilier to setup a same env as the development.
Yarn is a package manager that uses NPM registry as its backend, but it’s more than npm, say NPM installs packages sequentially. This slows down the performance significantly. Yarn solves this problem by installing these packages in parallel.
you can install pkg into global or particular project, for global part, there are several configs that control where to install, the global dir
is used to store installed packages the global bin
are symbol links to binary file installed at global dir
.
1 | $ yarn config list |
More command, refer to Yarn CLI.
create react app
1 | $ yarn global add create-react-app |
use json mock server from vs code
1 | # edit prj/package.json |
debug react app with chrome
- Install Chrome debugger for VS code
- Use the following config for your launch.jsonfile to configure the VS Code debugger and put it inside .vscode in your root folder
1
2
3
4
5
6
7
8
9
10
11
12{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src"
}
]
} - Start your React app by running yarn start in another terminal
1
$ BROWSER=none yarn start
- Start debugging in VS Code by pressing F5or by clicking the green debug icon
REF
Behide react-create-app