Skip to content

Sync with reactjs.org @ 99a18287 #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ Do you know of a local React.js conference? Add it here! (Please keep the list c

## Upcoming Conferences {#upcoming-conferences}

### React Summit 2019 {#reactsummit2019}
November 30, 2019 in Lagos, Nigeria

[Website](https://reactsummit2019.splashthat.com) -[Twitter](https://twitter.com/react_summit)

### React Day Berlin 2019 {#react-day-berlin-2019}
December 6, 2019 in Berlin, Germany

[Website](https://reactday.berlin) - [Twitter](https://twitter.com/reactdayberlin) - [Facebook](https://www.facebook.com/reactdayberlin/) - [Videos](https://www.youtube.com/reactdayberlin)

### React Barcamp Cologne 2020 {#react-barcamp-cologne-2020}
February 1-2, 2020 in Cologne, Germany

Expand Down Expand Up @@ -82,6 +72,15 @@ July 17, 2020. New York City, USA.

[Website](https://reactweek.nyc/) - [Twitter](https://twitter.com/reactweek) - [Facebook](https://www.facebook.com/reactweek)

### ComponentsConf 2020 {#components20}
September 1, 2020 in Melbourne, Australia

[Website](https://www.componentsconf.com.au/) - [Twitter](https://twitter.com/ComponentsConf) - [Facebook](https://www.facebook.com/ComponentsConf/) - [LinkedIn](https://www.linkedin.com/company/componentsconf/) - [YouTube](https://www.youtube.com/ComponentsConf)

### React India 2020 {#react-india-2020}
November 6, 2020 in Mumbai, India

[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia/) - [LinkedIn](https://www.linkedin.com/showcase/14545585) - [YouTube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w/videos)

## Past Conferences {#past-conferences}

Expand Down Expand Up @@ -476,3 +475,14 @@ October 25, 2019 in London, UK
October 19, 2019 in São Paulo, BR

[Website](https://reactconf.com.br/) - [Twitter](https://twitter.com/reactconfbr) - [Facebook](https://www.facebook.com/ReactAdvanced) - [Slack](https://react.now.sh/)

### React Summit 2019 {#reactsummit2019}
November 30, 2019 in Lagos, Nigeria

[Website](https://reactsummit2019.splashthat.com) -[Twitter](https://twitter.com/react_summit)

### React Day Berlin 2019 {#react-day-berlin-2019}
December 6, 2019 in Berlin, Germany

[Website](https://reactday.berlin) - [Twitter](https://twitter.com/reactdayberlin) - [Facebook](https://www.facebook.com/reactdayberlin/) - [Videos](https://www.youtube.com/reactdayberlin)

1 change: 1 addition & 0 deletions content/community/meetups.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
* [Portland, OR - ReactJS](https://www.meetup.com/Portland-ReactJS/)
* [Provo, UT - ReactJS](https://www.meetup.com/ReactJS-Utah/)
* [Sacramento, CA - ReactJS](https://www.meetup.com/Sacramento-ReactJS-Meetup/)
* [San Diego, CA - San Diego JS](https://www.meetup.com/sandiegojs/)
* [San Francisco - Real World React](https://www.meetup.com/Real-World-React)
* [San Francisco - ReactJS](https://www.meetup.com/ReactJS-San-Francisco/)
* [San Francisco, CA - React Native](https://www.meetup.com/React-Native-San-Francisco/)
Expand Down
16 changes: 8 additions & 8 deletions content/docs/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function Page(props) {

This pattern is sufficient for many cases when you need to decouple a child from its immediate parents. You can take it even further with [render props](/docs/render-props.html) if the child needs to communicate with the parent before rendering.

However, sometimes the same data needs to be accessible by many components in the tree, and at different nesting levels. Context lets you "broadcast" such data, and changes to it, to all components below. Common examples where using context might be simpler than the alternatives include managing the current locale, theme, or a data cache.
However, sometimes the same data needs to be accessible by many components in the tree, and at different nesting levels. Context lets you "broadcast" such data, and changes to it, to all components below. Common examples where using context might be simpler than the alternatives include managing the current locale, theme, or a data cache.

## API {#api}

Expand All @@ -130,12 +130,12 @@ Every Context object comes with a Provider React component that allows consuming

Accepts a `value` prop to be passed to consuming components that are descendants of this Provider. One Provider can be connected to many consumers. Providers can be nested to override values deeper within the tree.

All consumers that are descendants of a Provider will re-render whenever the Provider's `value` prop changes. The propagation from Provider to its descendant consumers is not subject to the `shouldComponentUpdate` method, so the consumer is updated even when an ancestor component bails out of the update.
All consumers that are descendants of a Provider will re-render whenever the Provider's `value` prop changes. The propagation from Provider to its descendant consumers (including [`.contextType`](#classcontexttype) and [`useContext`](/docs/hooks-reference.html#usecontext)) is not subject to the `shouldComponentUpdate` method, so the consumer is updated even when an ancestor component skips an update.

Changes are determined by comparing the new and old values using the same algorithm as [`Object.is`](//developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#Description).
Changes are determined by comparing the new and old values using the same algorithm as [`Object.is`](//developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#Description).

> Note
>
>
> The way changes are determined can cause some issues when passing objects as `value`: see [Caveats](#caveats).

### `Class.contextType` {#classcontexttype}
Expand Down Expand Up @@ -194,7 +194,7 @@ A React component that subscribes to context changes. This lets you subscribe to
Requires a [function as a child](/docs/render-props.html#using-props-other-than-render). The function receives the current context value and returns a React node. The `value` argument passed to the function will be equal to the `value` prop of the closest Provider for this context above in the tree. If there is no Provider for this context above, the `value` argument will be equal to the `defaultValue` that was passed to `createContext()`.

> Note
>
>
> For more information about the 'function as a child' pattern, see [render props](/docs/render-props.html).

### `Context.displayName` {#contextdisplayname}
Expand Down Expand Up @@ -241,7 +241,7 @@ It is often necessary to update the context from a component that is nested some

### Consuming Multiple Contexts {#consuming-multiple-contexts}

To keep context re-rendering fast, React needs to make each context consumer a separate node in the tree.
To keep context re-rendering fast, React needs to make each context consumer a separate node in the tree.

`embed:context/multiple-contexts.js`

Expand All @@ -261,6 +261,6 @@ To get around this, lift the value into the parent's state:
## Legacy API {#legacy-api}

> Note
>
>
> React previously shipped with an experimental context API. The old API will be supported in all 16.x releases, but applications using it should migrate to the new version. The legacy API will be removed in a future major React version. Read the [legacy context docs here](/docs/legacy-context.html).

2 changes: 1 addition & 1 deletion content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Ha a saját kódszerkesztődet használnád, [letöltheted ezt a HTML fájlt](ht

Ha egy új React projektbe kezdesz, egy [egyszerű HTML oldal script tagekkel](/docs/add-react-to-a-website.html) lehet a legjobb megoldás. Csak egy percbe telik beállítani!

Ahogy az alkalmazásod nőni kezd, elkezdhetsz gondolkodni egy integráltabb megoldásban. Többféle [JavaScript eszközlánc is létezik](/docs/create-a-new-react-app.html), amit nagyobb alkamazásokhoz ajánlunk. Ezek mindegyike csak kevés vagy szinte semmilyen konfigurációt nem igényel és segítségükkel teljes hozzáférést nyersz a gazdag React ökoszisztémához.
Ahogy az alkalmazásod nőni kezd, elkezdhetsz gondolkodni egy integráltabb megoldásban. Többféle JavaScript eszközláncot is ajánlunk nagyobb alkalmazásokhoz. Ezek mindegyike csak kevés vagy szinte semmilyen konfigurációt nem igényel és segítségükkel teljes hozzáférést nyersz a gazdag React ökoszisztémához. [Tanuld meg hogyan.](/docs/create-a-new-react-app.html)

## Tanuld meg a Reactet {#learn-react}

Expand Down
10 changes: 6 additions & 4 deletions content/docs/hooks-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ Here, we store the previous value of the `row` prop in a state variable so that

```js
function ScrollView({row}) {
let [isScrollingDown, setIsScrollingDown] = useState(false);
let [prevRow, setPrevRow] = useState(null);
const [isScrollingDown, setIsScrollingDown] = useState(false);
const [prevRow, setPrevRow] = useState(null);

if (row !== prevRow) {
// Row changed since last render. Update isScrollingDown.
Expand Down Expand Up @@ -465,7 +465,7 @@ While you shouldn't need this often, you may expose some imperative methods to a

### How can I measure a DOM node? {#how-can-i-measure-a-dom-node}

In order to measure the position or size of a DOM node, you can use a [callback ref](/docs/refs-and-the-dom.html#callback-refs). React will call that callback whenever the ref gets attached to a different node. Here is a [small demo](https://codesandbox.io/s/l7m0v5x4v9):
One rudimentary way to measure the position or size of a DOM node is to use a [callback ref](/docs/refs-and-the-dom.html#callback-refs). React will call that callback whenever the ref gets attached to a different node. Here is a [small demo](https://codesandbox.io/s/l7m0v5x4v9):

```js{4-8,12}
function MeasureExample() {
Expand All @@ -490,6 +490,8 @@ We didn't choose `useRef` in this example because an object ref doesn't notify u

Note that we pass `[]` as a dependency array to `useCallback`. This ensures that our ref callback doesn't change between the re-renders, and so React won't call it unnecessarily.

In this example, the callback ref will be called only when the component mounts and unmounts, since the rendered `<h1>` component stays present throughout any rerenders. If you want to be notified any time a component resizes, you may want to use [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) or a third-party Hook built on it.

If you want, you can [extract this logic](https://codesandbox.io/s/m5o42082xy) into a reusable Hook:

```js{2}
Expand Down Expand Up @@ -716,7 +718,7 @@ As a last resort, if you want something like `this` in a class, you can [use a r
```js{2-6,10-11,16}
function Example(props) {
// Keep latest props in a ref.
let latestProps = useRef(props);
const latestProps = useRef(props);
useEffect(() => {
latestProps.current = props;
});
Expand Down
4 changes: 3 additions & 1 deletion content/docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function Counter({initialCount}) {

The "+" and "-" buttons use the functional form, because the updated value is based on the previous value. But the "Reset" button uses the normal form, because it always sets the count back to the initial value.

If your update function returns the exact same value, the subsequent rerender will be skipped completely.

> Note
>
> Unlike the `setState` method found in class components, `useState` does not automatically merge update objects. You can replicate this behavior by combining the function updater form with object spread syntax:
Expand Down Expand Up @@ -180,7 +182,7 @@ const value = useContext(MyContext);

Accepts a context object (the value returned from `React.createContext`) and returns the current context value for that context. The current context value is determined by the `value` prop of the nearest `<MyContext.Provider>` above the calling component in the tree.

When the nearest `<MyContext.Provider>` above the component updates, this Hook will trigger a rerender with the latest context `value` passed to that `MyContext` provider.
When the nearest `<MyContext.Provider>` above the component updates, this Hook will trigger a rerender with the latest context `value` passed to that `MyContext` provider. Even if an ancestor uses [`React.memo`](/docs/react-api.html#reactmemo) or [`shouldComponentUpdate`](/docs/react-component.html#shouldcomponentupdate), a rerender will still happen starting at the component itself using `useContext`.

Don't forget that the argument to `useContext` must be the *context object itself*:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/hooks-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ npm install eslint-plugin-react-hooks --save-dev
}
```

In the future, we intend to include this plugin by default into Create React App and similar toolkits.
This plugin is included by default in [Create React App](/docs/create-a-new-react-app.html#create-react-app).

**You can skip to the next page explaining how to write [your own Hooks](/docs/hooks-custom.html) now.** On this page, we'll continue by explaining the reasoning behind these rules.

Expand Down
2 changes: 1 addition & 1 deletion content/docs/introducing-jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ A következő szekcióban megvizsgáljuk a React elemek DOM-ba való renderelés

>**Tipp:**
>
>Javasoljuk, hogy általad használt kódszerkesztőben használd a ["Babel" nyelvdefiníciót](https://babeljs.io/docs/editors), így az ES6 és JSX kódrészek is helyesen lesznek kiemelve. Ez a weboldal az [Oceanic Next](https://labs.voronianski.com/oceanic-next-color-scheme/) színsémát használja, ami ezzel kompatibilis.
>Javasoljuk, hogy általad használt kódszerkesztőben használd a ["Babel" nyelvdefiníciót](https://babeljs.io/docs/editors), így az ES6 és JSX kódrészek is helyesen lesznek kiemelve.
2 changes: 1 addition & 1 deletion content/docs/optimizing-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ To do this in Chrome:

6. React events will be grouped under the **User Timing** label.

For a more detailed walkthrough, check out [this article by Ben Schwarz](https://building.calibreapp.com/debugging-react-performance-with-react-16-and-chrome-devtools-c90698a522ad).
For a more detailed walkthrough, check out [this article by Ben Schwarz](https://calibreapp.com/blog/react-performance-profiling-optimization).

Note that **the numbers are relative so components will render faster in production**. Still, this should help you realize when unrelated UI gets updated by mistake, and how deep and how often your UI updates occur.

Expand Down
4 changes: 3 additions & 1 deletion content/docs/reference-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o

### `React.PureComponent` {#reactpurecomponent}

`React.PureComponent` is similar to [`React.Component`](#reactcomponent). The difference between them is that [`React.Component`](#reactcomponent) doesn't implement [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate), but `React.PureComponent` implements it with a shallow prop and state comparison.
`React.PureComponent` is similar to [`React.Component`](#reactcomponent). The difference between them is that [`React.Component`](#reactcomponent) doesn't implement [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate), but `React.PureComponent` implements it with a shallow prop and state comparison.

If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases.

Expand All @@ -128,6 +128,8 @@ const MyComponent = React.memo(function MyComponent(props) {

If your function component renders the same result given the same props, you can wrap it in a call to `React.memo` for a performance boost in some cases by memoizing the result. This means that React will skip rendering the component, and reuse the last rendered result.

`React.memo` only affects props changes. If your function component wrapped in `React.memo` has a [`useState`](/docs/hooks-state.html) or [`useContext`](/docs/hooks-reference.html#usecontext) Hook in its implementation, it will still rerender when state or context change.

By default it will only shallowly compare complex objects in the props object. If you want control over the comparison, you can also provide a custom comparison function as the second argument.

```javascript
Expand Down
4 changes: 2 additions & 2 deletions content/docs/refs-and-the-dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CustomTextInput extends React.Component {

#### Refs and Function Components {#refs-and-function-components}

**You may not use the `ref` attribute on function components** because they don't have instances:
By default, **you may not use the `ref` attribute on function components** because they don't have instances:

```javascript{1,8,13}
function MyFunctionComponent() {
Expand All @@ -161,7 +161,7 @@ class Parent extends React.Component {
}
```

You should convert the component to a class if you need a ref to it, just like you do when you need lifecycle methods or state.
If you want to allow people to take a `ref` to your function component, you can use [`forwardRef`](https://reactjs.org/docs/forwarding-refs.html) (possibly in conjunction with [`useImperativeHandle`](/docs/hooks-reference.html#useimperativehandle)), or you can convert the component to a class.

You can, however, **use the `ref` attribute inside a function component** as long as you refer to a DOM element or a class component:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/testing-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ Sometimes, you may not want to mock timers. For example, maybe you're testing an

### End-to-end tests {#end-to-end-tests-aka-e2e-tests}

End-to-end tests are useful for testing longer workflows, especially when they're critical to your business (such as payments or signups). For these tests, you'd probably want to test both how a real browser renders the whole app, fetches data from the real API endpoints, uses sessions and cookies, navigates between different links. You might also likely want to make assertions not just on the DOM state, but on the backing data as well (e.g. to verify whether the updates have been persisted to the database).
End-to-end tests are useful for testing longer workflows, especially when they're critical to your business (such as payments or signups). For these tests, you'd probably want to test how a real browser renders the whole app, fetches data from the real API endpoints, uses sessions and cookies, navigates between different links. You might also likely want to make assertions not just on the DOM state, but on the backing data as well (e.g. to verify whether the updates have been persisted to the database).

In this scenario, you would use a framework like [Cypress](https://www.cypress.io/) or a library like [puppeteer](https://github.com/GoogleChrome/puppeteer) so you can navigate between multiple routes and assert on side effects not just in the browser, but potentially on the backend as well.
4 changes: 2 additions & 2 deletions content/docs/testing-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,14 @@ it("changes value when clicked", () => {

// get ahold of the button element, and trigger some clicks on it
const button = document.querySelector("[data-testid=toggle]");
expect(button.innerHTML).toBe("Turn off");
expect(button.innerHTML).toBe("Turn on");

act(() => {
button.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});

expect(onChange).toHaveBeenCalledTimes(1);
expect(button.innerHTML).toBe("Turn on");
expect(button.innerHTML).toBe("Turn off");

act(() => {
for (let i = 0; i < 5; i++) {
Expand Down