React Series: Starting from a Scaffold - create-react-app

The React ecosystem is incredibly vast. If beginners want to directly experience the charm of React, here is an official scaffold. The usage is very simple.

create-react-app

Basic Usage

Install

npm install -g create-react-app

Create an app

create-react-app my-app
cd my-app/

File structure:

my-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│   └── favicon.ico
│   └── index.html
│   └── manifest.json
└── src
    └── App.css
    └── App.js
    └── App.test.js
    └── index.css
    └── index.js
    └── logo.svg
    └── registerServiceWorker.js

Start the app:

npm start

Open http://localhost:3000/ in your browser to see your app.

If you want to build your app:

npm run build

Features

  • No configuration needed;
  • Direct compilation for React, JSX, ES6 and Flow;
  • Development server;
  • Hot reloading in the browser;
  • Import CSS and images directly in JavaScript files;
  • Automatic CSS vendor prefixing, no need to add -webkit prefixes;
  • Built-in build command, compiles for production with sourcemaps.

Oh, and I stumbled upon another scaffold called create-react-native-app:

create-react-native-app

Article Link:

/en/archive/react-create-app/

# Related Articles