mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Run formatting over *.md files to prevent conflicts
This commit is contained in:
62
README.md
62
README.md
@@ -2,8 +2,8 @@
|
||||
|
||||
Create React apps with no build configuration.
|
||||
|
||||
* [Creating an App](#creating-an-app) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Creating an App](#creating-an-app) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
Create React App works on macOS, Windows, and Linux.<br>
|
||||
If something doesn’t work, please [file an issue](https://github.com/facebook/create-react-app/issues/new).
|
||||
@@ -16,7 +16,7 @@ cd my-app
|
||||
npm start
|
||||
```
|
||||
|
||||
*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
|
||||
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_
|
||||
|
||||
Then open [http://localhost:3000/](http://localhost:3000/) to see your app.<br>
|
||||
When you’re ready to deploy to production, create a minified bundle with `npm run build`.
|
||||
@@ -44,21 +44,23 @@ To create a new app, you may choose one of the following methods:
|
||||
npx create-react-app my-app
|
||||
```
|
||||
|
||||
*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
|
||||
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_
|
||||
|
||||
### npm
|
||||
|
||||
```sh
|
||||
npm init react-app my-app
|
||||
```
|
||||
*`npm init <initializer>` is available in npm 6+*
|
||||
|
||||
_`npm init <initializer>` is available in npm 6+_
|
||||
|
||||
### Yarn
|
||||
|
||||
```sh
|
||||
yarn create react-app my-app
|
||||
```
|
||||
*`yarn create` is available in Yarn 0.25+*
|
||||
|
||||
_`yarn create` is available in Yarn 0.25+_
|
||||
|
||||
It will create a directory called `my-app` inside the current folder.<br>
|
||||
Inside that directory, it will generate the initial project structure and install the transitive dependencies:
|
||||
@@ -173,24 +175,24 @@ Please refer to the [User Guide](https://github.com/facebook/create-react-app/bl
|
||||
|
||||
## Philosophy
|
||||
|
||||
* **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.
|
||||
- **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.
|
||||
|
||||
* **No Configuration Required:** You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.
|
||||
- **No Configuration Required:** You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.
|
||||
|
||||
* **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
|
||||
- **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
|
||||
|
||||
## What’s Included?
|
||||
|
||||
Your environment will have everything you need to build a modern single-page React app:
|
||||
|
||||
* React, JSX, ES6, and Flow syntax support.
|
||||
* Language extras beyond ES6 like the object spread operator.
|
||||
* Autoprefixed CSS, so you don’t need `-webkit-` or other prefixes.
|
||||
* A fast interactive unit test runner with built-in support for coverage reporting.
|
||||
* A live development server that warns about common mistakes.
|
||||
* A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
|
||||
* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria. (*Note: Using the service worker is opt-in as of `react-scripts@2.0.0` and higher*)
|
||||
* Hassle-free updates for the above tools with a single dependency.
|
||||
- React, JSX, ES6, and Flow syntax support.
|
||||
- Language extras beyond ES6 like the object spread operator.
|
||||
- Autoprefixed CSS, so you don’t need `-webkit-` or other prefixes.
|
||||
- A fast interactive unit test runner with built-in support for coverage reporting.
|
||||
- A live development server that warns about common mistakes.
|
||||
- A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
|
||||
- An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria. (_Note: Using the service worker is opt-in as of `react-scripts@2.0.0` and higher_)
|
||||
- Hassle-free updates for the above tools with a single dependency.
|
||||
|
||||
Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together.
|
||||
|
||||
@@ -200,25 +202,25 @@ The tradeoff is that **these tools are preconfigured to work in a specific way**
|
||||
|
||||
Create React App is a great fit for:
|
||||
|
||||
* **Learning React** in a comfortable and feature-rich development environment.
|
||||
* **Starting new single-page React applications.**
|
||||
* **Creating examples** with React for your libraries and components.
|
||||
- **Learning React** in a comfortable and feature-rich development environment.
|
||||
- **Starting new single-page React applications.**
|
||||
- **Creating examples** with React for your libraries and components.
|
||||
|
||||
Here’s a few common cases where you might want to try something else:
|
||||
|
||||
* If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
|
||||
- If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
|
||||
|
||||
* If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb), or [Neutrino](https://neutrino.js.org/) which are more flexible. For Rails specifically, you can use [Rails Webpacker](https://github.com/rails/webpacker).
|
||||
- If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb), or [Neutrino](https://neutrino.js.org/) which are more flexible. For Rails specifically, you can use [Rails Webpacker](https://github.com/rails/webpacker).
|
||||
|
||||
* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/).
|
||||
- If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/).
|
||||
|
||||
* If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
|
||||
- If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
|
||||
|
||||
* If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
|
||||
- If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
|
||||
|
||||
* If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
|
||||
- If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
|
||||
|
||||
* Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
|
||||
- Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
|
||||
|
||||
All of the above tools can work with little to no configuration.
|
||||
|
||||
@@ -237,9 +239,9 @@ Check out [Create React Native App](https://github.com/react-community/create-re
|
||||
|
||||
We are grateful to the authors of existing related projects for their ideas and collaboration:
|
||||
|
||||
* [@eanplatter](https://github.com/eanplatter)
|
||||
* [@insin](https://github.com/insin)
|
||||
* [@mxstbr](https://github.com/mxstbr)
|
||||
- [@eanplatter](https://github.com/eanplatter)
|
||||
- [@insin](https://github.com/insin)
|
||||
- [@mxstbr](https://github.com/mxstbr)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
|
||||
Please refer to its documentation:
|
||||
|
||||
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
## Usage in Create React App Projects
|
||||
|
||||
|
||||
@@ -18,14 +18,12 @@ handleClick() { // missing `event` argument
|
||||
|
||||
This package exports a list of globals that are often used by mistake. You can feed this list to a static analysis tool like ESLint to prevent their usage without an explicit `window.` qualifier.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install --save confusing-browser-globals
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
If you use Create React App, you don't need to configure anything, as this rule is already included in the default `eslint-config-react-app` preset.
|
||||
@@ -38,11 +36,10 @@ var restrictedGlobals = require('confusing-browser-globals');
|
||||
module.exports = {
|
||||
rules: {
|
||||
'no-restricted-globals': ['error'].concat(restrictedGlobals),
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
This package includes the global command for [Create React App](https://github.com/facebook/create-react-app).<br>
|
||||
Please refer to its documentation:
|
||||
|
||||
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
This package includes the shareable ESLint configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
|
||||
Please refer to its documentation:
|
||||
|
||||
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
## Usage in Create React App Projects
|
||||
|
||||
@@ -18,19 +18,19 @@ If you want to use this ESLint configuration in a project not built with Create
|
||||
|
||||
First, install this package, ESLint and the necessary plugins.
|
||||
|
||||
```sh
|
||||
npm install --save-dev eslint-config-react-app babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
|
||||
```
|
||||
```sh
|
||||
npm install --save-dev eslint-config-react-app babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
|
||||
```
|
||||
|
||||
Then create a file named `.eslintrc` with following contents in the root folder of your project:
|
||||
|
||||
```js
|
||||
{
|
||||
"extends": "react-app"
|
||||
}
|
||||
```
|
||||
```js
|
||||
{
|
||||
"extends": "react-app"
|
||||
}
|
||||
```
|
||||
|
||||
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
|
||||
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
|
||||
|
||||
## Accessibility Checks
|
||||
|
||||
@@ -57,11 +57,11 @@ The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen
|
||||
|
||||
If you want to enable even more accessibility rules, you can create an `.eslintrc` file in the root of your project with this content:
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
|
||||
"plugins": ["jsx-a11y"]
|
||||
}
|
||||
```
|
||||
```json
|
||||
{
|
||||
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
|
||||
"plugins": ["jsx-a11y"]
|
||||
}
|
||||
```
|
||||
|
||||
However, if you are using [Create React App](https://github.com/facebook/create-react-app) and have not ejected, any additional rules will only be displayed in the [IDE integrations](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor), but not in the browser or the terminal.
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
|
||||
Please refer to its documentation:
|
||||
|
||||
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
|
||||
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
|
||||
|
||||
@@ -18,11 +18,11 @@ Each time a new feature is added, it is advised to add at least one test coverin
|
||||
|
||||
Features are categorized by their scope:
|
||||
|
||||
- *env*, all those which deal with environment variables (e.g. `NODE_PATH`)
|
||||
|
||||
- *syntax*, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel**
|
||||
- _env_, all those which deal with environment variables (e.g. `NODE_PATH`)
|
||||
|
||||
- *webpack*, all those which make use of webpack settings, loaders or plugins
|
||||
- _syntax_, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel**
|
||||
|
||||
- _webpack_, all those which make use of webpack settings, loaders or plugins
|
||||
|
||||
### Using it as Unit Tests
|
||||
|
||||
@@ -41,13 +41,12 @@ Test are written in `integration/{env|syntax|webpack}.test.js`, depending on the
|
||||
|
||||
For every test case added there is just a little chore to do:
|
||||
|
||||
- a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature
|
||||
- a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature
|
||||
|
||||
- add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string
|
||||
|
||||
- add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string
|
||||
|
||||
An usual flow for the test itself is something similar to:
|
||||
|
||||
- add an `id` attribute in a target HTML tag in the feature itself
|
||||
|
||||
- since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly
|
||||
- add an `id` attribute in a target HTML tag in the feature itself
|
||||
|
||||
- since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly
|
||||
|
||||
Reference in New Issue
Block a user