Skip to content

Commit a840d56

Browse files
committedOct 19, 2018
Port documentation updates
1 parent 567921d commit a840d56

8 files changed

+92
-34
lines changed
 

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

+8
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ This will allow you to do imports like
3333
> **Tip:** You can opt into using this feature with [CSS modules](/docs/adding-a-css-modules-stylesheet) too!
3434
3535
> **Note:** You must prefix imports from `node_modules` with `~` as displayed above.
36+
37+
> **Note:** If you're using Flow, add the following to your `.flowconfig` so it'll recognize the `.sass` or `.scss` imports.
38+
>
39+
> ```
40+
> [options]
41+
> module.file_ext=.sass
42+
> module.file_ext=.scss
43+
> ```

‎docusaurus/docs/advanced-configuration.md

+13-12
Large diffs are not rendered by default.

‎docusaurus/docs/folder-structure.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ You may create subdirectories inside `src`. For faster rebuilds, only files insi
3434
Only files inside `public` can be used from `public/index.html`. Read instructions below for using assets from JavaScript and HTML.
3535

3636
You can, however, create more top-level directories. They will not be included in the production build so you can use them for things like documentation.
37+
38+
If you have Git installed and your project is not part of a larger repository, then a new repository will be initialized resulting in an additional top-level `.git` directory.

‎docusaurus/docs/making-a-progressive-web-app.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the build process will generate a service worker file, but it will not be
1010
registered, so it will not take control of your production web app.
1111

1212
In order to opt-in to the offline-first behavior, developers should look for the
13-
following in their [`src/index.js`](src/index.js) file:
13+
following in their [`src/index.js`](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/src/index.js) file:
1414

1515
```js
1616
// If you want your app to work offline and load faster, you can change
@@ -47,16 +47,32 @@ or unreliable network.
4747
If you do decide to opt-in to service worker registration, please take the
4848
following into account:
4949

50+
1. After the initial caching is done, the [service worker lifecycle](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle)
51+
controls when updated content ends up being shown to users. In order to guard against
52+
[race conditions with lazy-loaded content](https://github.com/facebook/create-react-app/issues/3613#issuecomment-353467430),
53+
the default behavior is to conservatively keep the updated service worker in the "[waiting](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting)"
54+
state. This means that users will end up seeing older content until they close (reloading is not
55+
enough) their existing, open tabs. See [this blog post](https://jeffy.info/2018/10/10/sw-in-c-r-a.html)
56+
for more details about this behavior.
57+
58+
1. Users aren't always familiar with offline-first web apps. It can be useful to
59+
[let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)
60+
when the service worker has finished populating your caches (showing a "This web
61+
app works offline!" message) and also let them know when the service worker has
62+
fetched the latest updates that will be available the next time they load the
63+
page (showing a "New content is available once existing tabs are closed." message). Showing
64+
this messages is currently left as an exercise to the developer, but as a
65+
starting point, you can make use of the logic included in [`src/serviceWorker.js`](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/src/serviceWorker.js), which
66+
demonstrates which service worker lifecycle events to listen for to detect each
67+
scenario, and which as a default, just logs appropriate messages to the
68+
JavaScript console.
69+
5070
1. Service workers [require HTTPS](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers#you_need_https),
5171
although to facilitate local testing, that policy
5272
[does not apply to `localhost`](http://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http/34161385#34161385).
5373
If your production web server does not support HTTPS, then the service worker
5474
registration will fail, but the rest of your web app will remain functional.
5575

56-
1. Service workers are [not supported](https://jakearchibald.github.io/isserviceworkerready/#moar)
57-
in older web browsers. Service worker registration [won't be attempted](src/registerServiceWorker.js)
58-
on browsers that lack support.
59-
6076
1. The service worker is only enabled in the [production environment](/docs/deployment),
6177
e.g. the output of `npm run build`. It's recommended that you do not enable an
6278
offline-first service worker in a development environment, as it can lead to
@@ -70,18 +86,6 @@ following into account:
7086
instructions for using other methods. _Be sure to always use an
7187
incognito window to avoid complications with your browser cache._
7288

73-
1. Users aren't always familiar with offline-first web apps. It can be useful to
74-
[let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)
75-
when the service worker has finished populating your caches (showing a "This web
76-
app works offline!" message) and also let them know when the service worker has
77-
fetched the latest updates that will be available the next time they load the
78-
page (showing a "New content is available; please refresh." message). Showing
79-
this messages is currently left as an exercise to the developer, but as a
80-
starting point, you can make use of the logic included in [`src/registerServiceWorker.js`](src/registerServiceWorker.js), which
81-
demonstrates which service worker lifecycle events to listen for to detect each
82-
scenario, and which as a default, just logs appropriate messages to the
83-
JavaScript console.
84-
8589
1. By default, the generated service worker file will not intercept or cache any
8690
cross-origin traffic, like HTTP [API requests](/docs/integrating-with-an-api-backend),
8791
images, or embeds loaded from a different domain.

‎docusaurus/docs/post-processing-css.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This project setup minifies your CSS and adds vendor prefixes to it automaticall
77

88
Support for new CSS features like the [`all` property](https://developer.mozilla.org/en-US/docs/Web/CSS/all), [`break` properties](https://www.w3.org/TR/css-break-3/#breaking-controls), [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables), and [media query ranges](https://www.w3.org/TR/mediaqueries-4/#range-context) are automatically polyfilled to add support for older browsers.
99

10-
You can customize your target support browsers by adjusting the `browserslist` key in `package.json` accoring to the [Browserslist specification](https://github.com/browserslist/browserslist#readme).
10+
You can customize your target support browsers by adjusting the `browserslist` key in `package.json` according to the [Browserslist specification](https://github.com/browserslist/browserslist#readme).
1111

1212
For example, this:
1313

‎docusaurus/docs/running-tests.md

+45-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ This test mounts a component and makes sure that it didn’t throw during render
8282

8383
When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior.
8484

85+
### Option 1: Shallow Rendering
86+
8587
If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run:
8688

8789
```sh
@@ -167,6 +169,47 @@ Import it in [`src/setupTests.js`](#initializing-test-environment) to make its m
167169
import 'jest-enzyme';
168170
```
169171

172+
### Option 2: React Testing Library
173+
174+
As an alternative or companion to `enzyme`, you may consider using `react-testing-library`. [`react-testing-library`](https://github.com/kentcdodds/react-testing-library) is a library for testing React components in a way that resembles the way the components are used by end users. It is well suited for unit, integration, and end-to-end testing of React components and applications. It works more directly with DOM nodes, and therefore it's recommended to use with [`jest-dom`](https://github.com/gnapse/jest-dom) for improved assertions.
175+
176+
To install `react-testing-library` and `jest-dom`, you can run:
177+
178+
```sh
179+
npm install --save react-testing-library jest-dom
180+
```
181+
182+
Alternatively you may use `yarn`:
183+
184+
```sh
185+
yarn add react-testing-library jest-dom
186+
```
187+
188+
Similar to `enzyme` you can create a `src/setupTests.js` file to avoid boilerplate in your test files:
189+
190+
```js
191+
// react-testing-library renders your components to document.body,
192+
// this will ensure they're removed after each test.
193+
import 'react-testing-library/cleanup-after-each';
194+
// this adds jest-dom's custom assertions
195+
import 'jest-dom/extend-expect';
196+
```
197+
198+
Here's an example of using `react-testing-library` and `jest-dom` for testing that the `<App />` component renders "Welcome to React".
199+
200+
```js
201+
import React from 'react';
202+
import { render } from 'react-testing-library';
203+
import App from './App';
204+
205+
it('renders welcome message', () => {
206+
const { getByText } = render(<App />);
207+
expect(getByText('Welcome to React')).toBeInTheDocument();
208+
});
209+
```
210+
211+
Learn more about the utilities provided by `react-testing-library` to facilitate testing asynchronous interactions as well as selecting form elements from [the `react-testing-library` documentation](https://github.com/kentcdodds/react-testing-library) and [examples](https://codesandbox.io/s/github/kentcdodds/react-testing-library-examples).
212+
170213
## Using Third Party Assertion Libraries
171214

172215
We recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566).
@@ -309,11 +352,11 @@ set CI=true&&npm run build
309352
#### Windows (Powershell)
310353

311354
```Powershell
312-
($env:CI = $true) -and (npm test)
355+
($env:CI = "true") -and (npm test)
313356
```
314357

315358
```Powershell
316-
($env:CI = $true) -and (npm run build)
359+
($env:CI = "true") -and (npm run build)
317360
```
318361

319362
#### Linux, macOS (Bash)

‎docusaurus/docs/using-https-in-development.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set HTTPS=true&&npm start
2121
### Windows (Powershell)
2222

2323
```Powershell
24-
($env:HTTPS = $true) -and (npm start)
24+
($env:HTTPS = "true") -and (npm start)
2525
```
2626

2727
### Linux, macOS (Bash)

‎docusaurus/website/i18n/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"localized-strings": {
44
"next": "Next",
55
"previous": "Previous",
6-
"tagline": "Create React apps with no build configuration.",
6+
"tagline": "Set up a modern web app by running one command.",
77
"docs": {
88
"adding-a-css-modules-stylesheet": {
99
"title": "Adding A CSS Modules Stylesheet",

0 commit comments

Comments
 (0)