Skip to content

Commit fda5d5c

Browse files
authored
Merge pull request #99 from facebook/master
merging upstream master
2 parents 1b5aa70 + 126bded commit fda5d5c

File tree

94 files changed

+4982
-4017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+4982
-4017
lines changed

.github/stale.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ exemptLabels:
1616
- "issue: bug"
1717
- "issue: needs investigation"
1818
- "issue: proposal"
19-
- "tag: bug fix"
2019
- "tag: breaking change"
20+
- "tag: bug fix"
21+
- "tag: documentation"
22+
- "tag: enhancement"
23+
- "tag: internal"
24+
- "tag: new feature"
25+
- "tag: underlying tools"
2126

2227
# Set to true to ignore issues in a project (defaults to false)
2328
exemptProjects: true

CHANGELOG-2.x.md

Lines changed: 1390 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 193 additions & 1316 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ By default git would use `CRLF` line endings which would cause the scripts to fa
152152
9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
153153
10. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
154154

155-
Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --canary=next --exact --cd-version patch --npm-tag=next` instead of `npm run publish`.
155+
Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- prepatch --canary --preid next --dist-tag next --npm-client npm --force-publish` instead of `npm run publish`.
156156

157157
---
158158

docusaurus/docs/adding-a-sass-stylesheet.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ If you set `SASS_PATH=node_modules:src`, this will allow you to do imports like
4242
@import 'nprogress/nprogress'; // importing a css file from the nprogress node module
4343
```
4444

45+
> **Note:** For windows operating system, use below syntax
46+
>
47+
> ```
48+
> SASS_PATH=./node_modules;./src
49+
> ```
50+
4551
> **Tip:** You can opt into using this feature with [CSS modules](adding-a-css-modules-stylesheet.md) too!
4652
4753
> **Note:** If you're using Flow, override the [module.file_ext](https://flow.org/en/docs/config/options/#toc-module-file-ext-string) setting in your `.flowconfig` so it'll recognize `.sass` or `.scss` files. You will also need to include the `module.file_ext` default settings for `.js`, `.jsx`, `.mjs` and `.json` files.

docusaurus/docs/adding-bootstrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: adding-bootstrap
33
title: Adding Bootstrap
44
---
55

6-
While you don’t have to use any specific library to integrate Bootstrap with React apps, it's often easier than trying to wrap the Bootstrap jQuery plugins. [React Bootstrap](https://react-bootstrap.netlify.com/) is the most popular option, that strives for complete parity with bootstrap. [reactstrap](https://reactstrap.github.io/) is also a good choice for projects looking for smaller builds at the expense of some features.
6+
While you don’t have to use any specific library to integrate Bootstrap with React apps, it's often easier than trying to wrap the Bootstrap jQuery plugins. [React Bootstrap](https://react-bootstrap.netlify.com/) is the most popular option that strives for complete parity with Bootstrap. [reactstrap](https://reactstrap.github.io/) is also a good choice for projects looking for smaller builds at the expense of some features.
77

88
Each project's respective documentation site has detailed instructions for installing and using them. Both depend on the Bootstrap css file so install that as well:
99

docusaurus/docs/adding-css-reset.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
id: adding-css-reset
3+
title: Adding a CSS Reset
4+
sidebar_label: Adding CSS Reset
5+
---
6+
7+
This project setup uses [PostCSS Normalize] for adding a [CSS Reset].
8+
9+
To start using it, add `@import-normalize;` anywhere in your CSS file(s). You only need to include it once and duplicate imports are automatically removed. Since you only need to include it once, a good place to add it is `index.css` or `App.css`.
10+
11+
## `index.css`
12+
13+
```css
14+
@import-normalize; /* bring in normalize.css styles */
15+
16+
/* rest of app styles */
17+
```
18+
19+
You can control which parts of [normalize.css] to use via your project's [browserslist].
20+
21+
Results when [browserslist] is `last 3 versions`:
22+
23+
```css
24+
/**
25+
* Add the correct display in IE 9-.
26+
*/
27+
28+
audio,
29+
video {
30+
display: inline-block;
31+
}
32+
33+
/**
34+
* Remove the border on images inside links in IE 10-.
35+
*/
36+
37+
img {
38+
border-style: none;
39+
}
40+
```
41+
42+
Results when [browserslist] is `last 2 versions`:
43+
44+
```css
45+
/**
46+
* Remove the border on images inside links in IE 10-.
47+
*/
48+
49+
img {
50+
border-style: none;
51+
}
52+
```
53+
54+
## Browser support
55+
56+
Browser support is dictated by what normalize.css [supports]. As of this writing, it includes:
57+
58+
- Chrome (last 3)
59+
- Edge (last 3)
60+
- Firefox (last 3)
61+
- Firefox ESR
62+
- Opera (last 3)
63+
- Safari (last 3)
64+
- iOS Safari (last 2)
65+
- Internet Explorer 9+
66+
67+
[browserslist]: http://browserl.ist/
68+
[css reset]: https://cssreset.com/what-is-a-css-reset/
69+
[normalize.css]: https://github.com/csstools/normalize.css
70+
[supports]: https://github.com/csstools/normalize.css#browser-support
71+
[postcss normalize]: https://github.com/csstools/postcss-normalize

docusaurus/docs/adding-images-fonts-and-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ An alternative way of handling static assets is described in the next section.
4444

4545
## Adding SVGs
4646

47-
> Note: this feature is available with `[email protected]` and higher.
47+
> Note: this feature is available with `[email protected]` and higher, and `[email protected]` and higher.
4848
4949
One way to add SVG files was described in the section above. You can also import SVGs directly as React components. You can use either of the two approaches. In your code it would look like this:
5050

docusaurus/docs/adding-typescript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Type errors will show up in the same console as the build one.
3333

3434
To learn more about TypeScript, check out [its documentation](https://www.typescriptlang.org/).
3535

36+
> **Note:** If your project is not created with TypeScript enabled, npx may be using a cached version of `create-react-app`.
37+
> Remove previously installed versions with `npm uninstall -g create-react-app` (see [#6119](https://github.com/facebook/create-react-app/issues/6119#issuecomment-451614035)).
38+
3639
> **Note:** You are not required to make a [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html), one will be made for you.
3740
> You are allowed to edit the generated TypeScript configuration.
3841

docusaurus/docs/advanced-configuration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ id: advanced-configuration
33
title: Advanced Configuration
44
---
55

6-
You can adjust various development and production settings by setting environment variables in your shell or with [.env](adding-custom-environment-variables.md#adding-development-environment-variables-in-env).
6+
You can adjust various development and production settings by setting environment variables in your shell or with [.env](adding-custom-environment-variables.md#adding-development-environment-variables-in-env).
7+
8+
> Note: You do not need to declare `REACT_APP_` before the below variables as you would with custom environment variables.
79
810
| Variable | Development | Production | Usage |
911
| :------------------- | :---------: | :--------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

docusaurus/docs/available-scripts.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Your app is ready to be deployed! See the section about [deployment](deployment.
3030

3131
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
3232

33-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
33+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc.) into your project as dependencies in `package.json`. Technically, the distinction between dependencies and development dependencies is pretty arbitrary for front-end apps that produce static bundles.
34+
35+
In addition, it used to cause problems with some hosting platforms that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment). You are free to rearrange your dependencies in `package.json` as you see fit.
36+
37+
All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
3438

3539
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

docusaurus/docs/debugging-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Use the following [`launch.json`](https://code.visualstudio.com/docs/editor/debu
5555
"test",
5656
"--runInBand",
5757
"--no-cache",
58-
"--no-watch"
58+
"--watchAll=false"
5959
],
6060
"cwd": "${workspaceRoot}",
6161
"protocol": "inspector",

docusaurus/docs/deployment.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ service worker navigation routing can be configured or disabled by
9090
[`eject`ing](available-scripts.md#npm-run-eject) and then modifying the
9191
[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string)
9292
and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp)
93-
options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js).
93+
options of the `SWPrecachePlugin` [configuration](../config/webpack.config.prod.js).
9494

9595
When users install your app to the homescreen of their device the default configuration will make a shortcut to `/index.html`. This may not work for client-side routers which expect the app to be served from `/`. Edit the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to match the required URL scheme, for example:
9696

@@ -160,6 +160,17 @@ You can specify other environments in the same way.
160160

161161
Variables in `.env.production` will be used as fallback because `NODE_ENV` will always be set to `production` for a build.
162162

163+
## [AWS Amplify](http://console.amplify.aws)
164+
165+
The AWS Amplify Console provides continuous deployment and hosting for modern web apps (single page apps and static site generators) with serverless backends. The Amplify Console offers globally available CDNs, easy custom domain setup, feature branch deployments, and password protection.
166+
167+
1. Login to the Amplify Console [here](https://console.aws.amazon.com/amplify/home).
168+
1. Connect your Create React App repo and pick a branch. If you're looking for a Create React App+Amplify starter, try the [create-react-app-auth-amplify starter](https://github.com/swaminator/create-react-app-auth-amplify) that demonstrates setting up auth in 10 minutes with Create React App.
169+
1. The Amplify Console automatically detects the build settings. Choose Next.
170+
1. Choose _Save and deploy_.
171+
172+
If the build succeeds, the app is deployed and hosted on a global CDN with an amplifyapp.com domain. You can now continuously deploy changes to your frontend or backend. Continuous deployment allows developers to deploy updates to their frontend and backend on every code commit to their Git repository.
173+
163174
## [Azure](https://azure.microsoft.com/)
164175

165176
See [this](https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321) blog post on how to deploy your React app to Microsoft Azure.
@@ -443,10 +454,18 @@ To deploy your built project directly with Now CLI in your terminal, without any
443454
444455
3. Run `now --name your-project-name` from within the build directory. You will be given a **now.sh** URL as a response as your build is deployed, similar to the following: https://my-cra-project-4rx7b16z3.now.sh/
445456
446-
Click or paste the deployment URL into your browser when the build is complete and you will see your deployed app.
457+
Click or paste the deployment URL into your browser when the build is complete and you will see your deployed app.
447458
448459
For more information on deploying React applications with Now, including automatically building your application fresh in the cloud, setting up routes to rewrite all paths to the index.html file, and setting up caching headers for speed, see [the ZEIT Guide for Deploying a React app with Create React App](https://zeit.co/guides/deploying-react-with-now-cra/).
449460
461+
## [Render](https://render.com)
462+
463+
Render offers free [static site](https://render.com/docs/static-sites) hosting with fully managed SSL, a global CDN and continuous auto deploys from GitHub.
464+
465+
Deploy your app in just a few minutes by following the [Create React App deployment guide](https://render.com/docs/deploy-create-react-app).
466+
467+
Use invite code `cra` to sign up or use [this link](https://render.com/i/cra).
468+
450469
## [S3](https://aws.amazon.com/s3) and [CloudFront](https://aws.amazon.com/cloudfront/)
451470
452471
See this [blog post](https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af) on how to deploy your React app to Amazon Web Services S3 and CloudFront.

docusaurus/docs/getting-started.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Just create a project, and you’re good to go.
3434

3535
## Creating an App
3636

37-
**You’ll need to have Node >= 6 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
37+
**You’ll need to have Node >= 8.10 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
3838

3939
To create a new app, you may choose one of the following methods:
4040

@@ -62,6 +62,10 @@ yarn create react-app my-app
6262

6363
_`yarn create` is available in Yarn 0.25+_
6464

65+
### Creating a TypeScript app
66+
67+
Follow our [Adding TypeScript](adding-typescript.md) documentation to create a TypeScript app.
68+
6569
## Output
6670

6771
Running any of these commands will create a directory called `my-app` inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies:

docusaurus/docs/importing-a-component.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,28 @@ Learn more about ES6 modules:
4848
- [When to use the curly braces?](https://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281)
4949
- [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)
5050
- [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)
51+
52+
## Absolute Imports
53+
54+
You can configure your application to support importing modules using absolute paths. This can be done by configuring a `jsconfig.json` or `tsconfig.json` file in the root of your project. If you're using TypeScript in your project, you will already have a `tsconfig.json` file.
55+
56+
Below is an example `jsconfig.json` file for a JavaScript project. You can create the file if it doesn't already exist:
57+
58+
```json
59+
{
60+
"compilerOptions": {
61+
"baseUrl": "src"
62+
},
63+
"include": ["src"]
64+
}
65+
```
66+
67+
If you're using TypeScript, you can configure the `baseUrl` setting inside the `compilerOptions` of your project's `tsconfig.json` file.
68+
69+
Now that you've configured your project to support absolute imports, if you want to import a module located at `src/components/Button.js`, you can import the module like so:
70+
71+
```js
72+
import Button from 'components/Button';
73+
```
74+
75+
For more information on these configuration files, see the [jsconfig.json reference](https://code.visualstudio.com/docs/languages/jsconfig) and [tsconfig.json reference](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) documentation.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
id: loading-graphql-files
3+
title: Loading .graphql Files
4+
sidebar_label: Loading .graphql Files
5+
---
6+
7+
To load `.gql` and `.graphql` files, first install the [`graphql.macro`](https://www.npmjs.com/package/graphql.macro) package by running:
8+
9+
```sh
10+
npm install --save graphql.macro
11+
```
12+
13+
Alternatively you may use `yarn`:
14+
15+
```sh
16+
yarn add graphql.macro
17+
```
18+
19+
Then, whenever you want to load `.gql` or `.graphql` files, import the `loader` from the macro package:
20+
21+
```js
22+
import { loader } from 'graphql.macro';
23+
24+
const query = loader('./foo.graphql');
25+
```
26+
27+
And your results get automatically inlined! This means that if the file above, `foo.graphql`, contains the following:
28+
29+
```graphql
30+
gql`
31+
query {
32+
hello {
33+
world
34+
}
35+
}
36+
`;
37+
```
38+
39+
The previous example turns into:
40+
41+
```javascript
42+
const query = {
43+
'kind': 'Document',
44+
'definitions': [{
45+
...
46+
}],
47+
'loc': {
48+
...
49+
'source': {
50+
'body': '\\\\n query {\\\\n hello {\\\\n world\\\\n }\\\\n }\\\\n',
51+
'name': 'GraphQL request',
52+
...
53+
}
54+
}
55+
};
56+
```
57+
58+
You can also use the `gql` template tag the same way you would use the non-macro version from `graphql-tag` package with the added benefit of inlined parsing results.
59+
60+
```js
61+
import { gql } from 'graphql.macro';
62+
63+
const query = gql`
64+
query User {
65+
user(id: 5) {
66+
lastName
67+
...UserEntry1
68+
}
69+
}
70+
`;
71+
```

docusaurus/docs/production-build.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ title: Creating a Production Build
55

66
`npm run build` creates a `build` directory with a production build of your app. Inside the `build/static` directory will be your JavaScript and CSS files. Each filename inside of `build/static` will contain a unique hash of the file contents. This hash in the file name enables [long term caching techniques](#static-file-caching).
77

8-
When running a production build of freshly created Create React App application, there are 3 `.js` files (called _chunks_) that are generated and placed in the `build/static/js` directory:
8+
When running a production build of freshly created Create React App application, there are a number of `.js` files (called _chunks_) that are generated and placed in the `build/static/js` directory:
99

1010
`main.[hash].chunk.js`
1111

1212
- This is your _application_ code. `App.js`, etc.
1313

14-
`1.[hash].chunk.js`
14+
`[number].[hash].chunk.js`
1515

16-
- This is your _vendor_ code, which includes modules you've imported from within `node_modules`. One of the potential advantages with splitting your _vendor_ and _application_ code is to enable [long term caching techniques](#static-file-caching) to improve application loading performance. Since _vendor_ code tends to change less often than the actual _application_ code, the browser will be able to cache them separately, and won't re-download them each time the app code changes.
16+
- These files can either be _vendor_ code, or [code splitting chunks](code-splitting.md). _Vendor_ code includes modules that you've imported from within `node_modules`. One of the potential advantages with splitting your _vendor_ and _application_ code is to enable [long term caching techniques](#static-file-caching) to improve application loading performance. Since _vendor_ code tends to change less often than the actual _application_ code, the browser will be able to cache them separately, and won't re-download them each time the app code changes.
1717

1818
`runtime~main.[hash].js`
1919

0 commit comments

Comments
 (0)