Browse Source

Link to beta in content (#5495)

main
dan 2 years ago
committed by GitHub
parent
commit
3b0be4fbef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      content/docs/components-and-props.md
  2. 9
      content/docs/conditional-rendering.md
  3. 9
      content/docs/context.md
  4. 10
      content/docs/forms.md
  5. 9
      content/docs/forwarding-refs.md
  6. 6
      content/docs/getting-started.md
  7. 9
      content/docs/handling-events.md
  8. 8
      content/docs/hooks-custom.md
  9. 10
      content/docs/hooks-effect.md
  10. 71
      content/docs/hooks-reference.md
  11. 9
      content/docs/hooks-state.md
  12. 9
      content/docs/introducing-jsx.md
  13. 8
      content/docs/lifting-state-up.md
  14. 9
      content/docs/lists-and-keys.md
  15. 8
      content/docs/portals.md
  16. 8
      content/docs/reconciliation.md
  17. 13
      content/docs/reference-dom-elements.md
  18. 8
      content/docs/reference-events.md
  19. 4
      content/docs/reference-react-component.md
  20. 9
      content/docs/reference-react-dom-client.md
  21. 24
      content/docs/reference-react-dom-server.md
  22. 25
      content/docs/reference-react-dom.md
  23. 56
      content/docs/reference-react.md
  24. 11
      content/docs/refs-and-the-dom.md
  25. 9
      content/docs/state-and-lifecycle.md
  26. 9
      content/docs/strict-mode.md
  27. 8
      content/docs/thinking-in-react.md
  28. 10
      content/docs/uncontrolled-components.md
  29. 8
      content/tutorial/tutorial.md

10
content/docs/components-and-props.md

@ -16,6 +16,16 @@ prev: rendering-elements.html
next: state-and-lifecycle.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Quick Start](https://beta.reactjs.org/learn)
> - [Your First Component](https://beta.reactjs.org/learn/your-first-component)
> - [Passing Props to a Component](https://beta.reactjs.org/learn/passing-props-to-a-component)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a [detailed component API reference here](/docs/react-component.html).
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen.

9
content/docs/conditional-rendering.md

@ -8,6 +8,15 @@ redirect_from:
- "tips/false-in-jsx.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Conditional Rendering](https://beta.reactjs.org/learn/conditional-rendering)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the state of your application.
Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like [`if`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) or the [conditional operator](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) to create elements representing the current state, and let React update the UI to match them.

9
content/docs/context.md

@ -4,6 +4,15 @@ title: Context
permalink: docs/context.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Passing Data Deeply with Context](https://beta.reactjs.org/learn/passing-data-deeply-with-context)
> - [`useContext`](https://beta.reactjs.org/reference/react/useContext)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Context provides a way to pass data through the component tree without having to pass props down manually at every level.
In a typical React application, data is passed top-down (parent to child) via props, but such usage can be cumbersome for certain types of props (e.g. locale preference, UI theme) that are required by many components within an application. Context provides a way to share values like these between components without having to explicitly pass a prop through every level of the tree.

10
content/docs/forms.md

@ -9,6 +9,16 @@ redirect_from:
- "docs/forms-zh-CN.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [`<input>`](https://beta.reactjs.org/reference/react-dom/components/input)
> - [`<select>`](https://beta.reactjs.org/reference/react-dom/components/select)
> - [`<textarea>`](https://beta.reactjs.org/reference/react-dom/components/textarea)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
HTML form elements work a bit differently from other DOM elements in React, because form elements naturally keep some internal state. For example, this form in plain HTML accepts a single name:
```html

9
content/docs/forwarding-refs.md

@ -4,6 +4,15 @@ title: Forwarding Refs
permalink: docs/forwarding-refs.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Manipulating the DOM with Refs](https://beta.reactjs.org/learn/manipulating-the-dom-with-refs)
> - [`forwardRef`](https://beta.reactjs.org/reference/react/forwardRef)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Ref forwarding is a technique for automatically passing a [ref](/docs/refs-and-the-dom.html) through a component to one of its children. This is typically not necessary for most components in the application. However, it can be useful for some kinds of components, especially in reusable component libraries. The most common scenarios are described below.
## Forwarding refs to DOM components {#forwarding-refs-to-dom-components}

6
content/docs/getting-started.md

@ -18,6 +18,12 @@ redirect_from:
- "docs/environments.html"
---
> Try the new React documentation.
>
> The new [Quick Start](https://beta.reactjs.org/learn) teaches modern React and include live examples.
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
This page is an overview of the React documentation and related resources.
**React** is a JavaScript library for building user interfaces. Learn what React is all about on [our homepage](/) or [in the tutorial](/tutorial/tutorial.html).

9
content/docs/handling-events.md

@ -8,6 +8,15 @@ redirect_from:
- "docs/events-ko-KR.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Responding to Events](https://beta.reactjs.org/learn/responding-to-events)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Handling events with React elements is very similar to handling events on DOM elements. There are some syntax differences:
* React events are named using camelCase, rather than lowercase.

8
content/docs/hooks-custom.md

@ -6,6 +6,14 @@ next: hooks-reference.html
prev: hooks-rules.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Reusing Logic with Custom Hooks](https://beta.reactjs.org/learn/reusing-logic-with-custom-hooks)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class.
Building your own Hooks lets you extract component logic into reusable functions.

10
content/docs/hooks-effect.md

@ -6,6 +6,16 @@ next: hooks-rules.html
prev: hooks-state.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Synchronizing with Effects](https://beta.reactjs.org/learn/synchronizing-with-effects)
> - [You Might Not Need an Effect](https://beta.reactjs.org/learn/you-might-not-need-an-effect)
> - [`useEffect`](https://beta.reactjs.org/reference/react/useEffect)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class.
The *Effect Hook* lets you perform side effects in function components:

71
content/docs/hooks-reference.md

@ -35,6 +35,10 @@ If you're new to Hooks, you might want to check out [the overview](/docs/hooks-o
### `useState` {#usestate}
> Try the new React documentation for [`useState`](https://beta.reactjs.org/reference/react/useState).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const [state, setState] = useState(initialState);
```
@ -118,6 +122,10 @@ In the rare case that you need to force the DOM update to be applied synchronous
### `useEffect` {#useeffect}
> Try the new React documentation for [`useEffect`](https://beta.reactjs.org/reference/react/useEffect).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
useEffect(didUpdate);
```
@ -197,6 +205,11 @@ The array of dependencies is not passed as arguments to the effect function. Con
### `useContext` {#usecontext}
> Try the new React documentation for [`useContext`](https://beta.reactjs.org/reference/react/useContext).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const value = useContext(MyContext);
```
@ -269,6 +282,11 @@ The following Hooks are either variants of the basic ones from the previous sect
### `useReducer` {#usereducer}
> Try the new React documentation for [`useReducer`](https://beta.reactjs.org/reference/react/useReducer).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const [state, dispatch] = useReducer(reducer, initialArg, init);
```
@ -372,6 +390,10 @@ Note that React may still need to render that specific component again before ba
### `useCallback` {#usecallback}
> Try the new React documentation for [`useCallback`](https://beta.reactjs.org/reference/react/useCallback).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const memoizedCallback = useCallback(
() => {
@ -395,6 +417,11 @@ Pass an inline callback and an array of dependencies. `useCallback` will return
### `useMemo` {#usememo}
> Try the new React documentation for [`useMemo`](https://beta.reactjs.org/reference/react/useMemo).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
```
@ -417,6 +444,11 @@ If no array is provided, a new value will be computed on every render.
### `useRef` {#useref}
> Try the new React documentation for [`useRef`](https://beta.reactjs.org/reference/react/useRef).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const refContainer = useRef(initialValue);
```
@ -454,6 +486,11 @@ Keep in mind that `useRef` *doesn't* notify you when its content changes. Mutati
### `useImperativeHandle` {#useimperativehandle}
> Try the new React documentation for [`useImperativeHandle`](https://beta.reactjs.org/reference/react/useImperativeHandle).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
useImperativeHandle(ref, createHandle, [deps])
```
@ -477,6 +514,11 @@ In this example, a parent component that renders `<FancyInput ref={inputRef} />`
### `useLayoutEffect` {#uselayouteffect}
> Try the new React documentation for [`useLayoutEffect`](https://beta.reactjs.org/reference/react/useLayoutEffect).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.
Prefer the standard `useEffect` when possible to avoid blocking visual updates.
@ -491,6 +533,11 @@ Prefer the standard `useEffect` when possible to avoid blocking visual updates.
### `useDebugValue` {#usedebugvalue}
> Try the new React documentation for [`useDebugValue`](https://beta.reactjs.org/reference/react/useDebugValue).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
useDebugValue(value)
```
@ -531,6 +578,11 @@ useDebugValue(date, date => date.toDateString());
### `useDeferredValue` {#usedeferredvalue}
> Try the new React documentation for [`useDeferredValue`](https://beta.reactjs.org/reference/react/useDeferredValue).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const deferredValue = useDeferredValue(value);
```
@ -569,6 +621,11 @@ Memoizing the children tells React that it only needs to re-render them when `de
### `useTransition` {#usetransition}
> Try the new React documentation for [`useTransition`](https://beta.reactjs.org/reference/react/useTransition).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const [isPending, startTransition] = useTransition();
```
@ -613,6 +670,11 @@ function App() {
### `useId` {#useid}
> Try the new React documentation for [`useId`](https://beta.reactjs.org/reference/react/useId).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const id = useId();
```
@ -669,6 +731,11 @@ The following Hooks are provided for library authors to integrate libraries deep
### `useSyncExternalStore` {#usesyncexternalstore}
> Try the new React documentation for [`useSyncExternalStore`](https://beta.reactjs.org/reference/react/useSyncExternalStore).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
const state = useSyncExternalStore(subscribe, getSnapshot[, getServerSnapshot]);
```
@ -715,6 +782,10 @@ const selectedField = useSyncExternalStore(
### `useInsertionEffect` {#useinsertioneffect}
> Try the new React documentation for [`useInsertionEffect`](https://beta.reactjs.org/reference/react/useInsertionEffect).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
useInsertionEffect(didUpdate);
```

9
content/docs/hooks-state.md

@ -6,6 +6,15 @@ next: hooks-effect.html
prev: hooks-overview.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [State: A Component's Memory](https://beta.reactjs.org/learn/state-a-components-memory)
> - [`useState`](https://beta.reactjs.org/reference/react/useState)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class.
The [introduction page](/docs/hooks-intro.html) used this example to get familiar with Hooks:

9
content/docs/introducing-jsx.md

@ -6,6 +6,15 @@ prev: hello-world.html
next: rendering-elements.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Writing Markup with JSX](https://beta.reactjs.org/learn/writing-markup-with-jsx)
> - [JavaScript in JSX with Curly Braces](https://beta.reactjs.org/learn/javascript-in-jsx-with-curly-braces)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Consider this variable declaration:
```js

8
content/docs/lifting-state-up.md

@ -9,6 +9,14 @@ redirect_from:
- "docs/flux-todo-list.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Sharing State Between Components](https://beta.reactjs.org/learn/sharing-state-between-components)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Often, several components need to reflect the same changing data. We recommend lifting the shared state up to their closest common ancestor. Let's see how this works in action.
In this section, we will create a temperature calculator that calculates whether the water would boil at a given temperature.

9
content/docs/lists-and-keys.md

@ -6,6 +6,15 @@ prev: conditional-rendering.html
next: forms.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Rendering Lists](https://beta.reactjs.org/learn/rendering-lists)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
First, let's review how you transform lists in JavaScript.
Given the code below, we use the [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function to take an array of `numbers` and double their values. We assign the new array returned by `map()` to the variable `doubled` and log it:

8
content/docs/portals.md

@ -4,6 +4,14 @@ title: Portals
permalink: docs/portals.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [`createPortal`](https://beta.reactjs.org/reference/react-dom/createPortal)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
```js

8
content/docs/reconciliation.md

@ -4,6 +4,14 @@ title: Reconciliation
permalink: docs/reconciliation.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Preserving and Resetting State](https://beta.reactjs.org/learn/preserving-and-resetting-state)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
React provides a declarative API so that you don't have to worry about exactly what changes on every update. This makes writing applications a lot easier, but it might not be obvious how this is implemented within React. This article explains the choices we made in React's "diffing" algorithm so that component updates are predictable while being fast enough for high-performance apps.
## Motivation {#motivation}

13
content/docs/reference-dom-elements.md

@ -14,6 +14,19 @@ redirect_from:
- "tips/dangerously-set-inner-html.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Common components (e.g. `<div>`)](https://beta.reactjs.org/reference/react-dom/components/common)
> - [`<input>`](https://beta.reactjs.org/reference/react-dom/components/input)
> - [`<option>`](https://beta.reactjs.org/reference/react-dom/components/option)
> - [`<progress>`](https://beta.reactjs.org/reference/react-dom/components/progress)
> - [`<select>`](https://beta.reactjs.org/reference/react-dom/components/select)
> - [`<textarea>`](https://beta.reactjs.org/reference/react-dom/components/textarea)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
React implements a browser-independent DOM system for performance and cross-browser compatibility. We took the opportunity to clean up a few rough edges in browser DOM implementations.
In React, all DOM properties and attributes (including event handlers) should be camelCased. For example, the HTML attribute `tabindex` corresponds to the attribute `tabIndex` in React. The exception is `aria-*` and `data-*` attributes, which should be lowercased. For example, you can keep `aria-label` as `aria-label`.

8
content/docs/reference-events.md

@ -6,6 +6,14 @@ layout: docs
category: Reference
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Common components (e.g. `<div>`)](https://beta.reactjs.org/reference/react-dom/components/common)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
This reference guide documents the `SyntheticEvent` wrapper that forms part of React's Event System. See the [Handling Events](/docs/handling-events.html) guide to learn more.
## Overview {#overview}

4
content/docs/reference-react-component.md

@ -15,6 +15,10 @@ redirect_from:
- "tips/use-react-with-other-libraries.html"
---
> Try the new React documentation for [`Component`](https://beta.reactjs.org/reference/react/Component).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
This page contains a detailed API reference for the React component class definition. It assumes you're familiar with fundamental React concepts, such as [Components and Props](/docs/components-and-props.html), as well as [State and Lifecycle](/docs/state-and-lifecycle.html). If you're not, read them first.
## Overview {#overview}

9
content/docs/reference-react-dom-client.md

@ -37,6 +37,10 @@ React supports all modern browsers, although [some polyfills are required](/docs
### `createRoot()` {#createroot}
> Try the new React documentation for [`createRoot`](https://beta.reactjs.org/reference/react-dom/client/createRoot).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
createRoot(container[, options]);
```
@ -70,6 +74,11 @@ root.unmount();
### `hydrateRoot()` {#hydrateroot}
> Try the new React documentation for [`hydrateRoot`](https://beta.reactjs.org/reference/react-dom/client/hydrateRoot).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
hydrateRoot(container, element[, options])
```

24
content/docs/reference-react-dom-server.md

@ -36,6 +36,10 @@ The following methods can be used in the environments that don't support streams
### `renderToPipeableStream()` {#rendertopipeablestream}
> Try the new React documentation for [`renderToPipeableStream`](https://beta.reactjs.org/reference/react-dom/server/renderToPipeableStream).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToPipeableStream(element, options)
```
@ -91,6 +95,10 @@ See the [full list of options](https://github.com/facebook/react/blob/14c2be8dac
### `renderToReadableStream()` {#rendertoreadablestream}
> Try the new React documentation for [`renderToReadableStream`](https://beta.reactjs.org/reference/react-dom/server/renderToReadableStream).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToReadableStream(element, options);
```
@ -148,6 +156,10 @@ See the [full list of options](https://github.com/facebook/react/blob/14c2be8dac
### `renderToNodeStream()` (Deprecated) {#rendertonodestream}
> Try the new React documentation for [`renderToNodeStream`](https://beta.reactjs.org/reference/react-dom/server/renderToNodeStream).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToNodeStream(element)
```
@ -166,6 +178,10 @@ If you call [`ReactDOM.hydrateRoot()`](/docs/react-dom-client.html#hydrateroot)
### `renderToStaticNodeStream()` {#rendertostaticnodestream}
> Try the new React documentation for [`renderToStaticNodeStream`](https://beta.reactjs.org/reference/react-dom/server/renderToStaticNodeStream).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToStaticNodeStream(element)
```
@ -186,6 +202,10 @@ If you plan to use React on the client to make the markup interactive, do not us
### `renderToString()` {#rendertostring}
> Try the new React documentation for [`renderToString`](https://beta.reactjs.org/reference/react-dom/server/renderToString).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToString(element)
```
@ -204,6 +224,10 @@ If you call [`ReactDOM.hydrateRoot()`](/docs/react-dom-client.html#hydrateroot)
### `renderToStaticMarkup()` {#rendertostaticmarkup}
> Try the new React documentation for [`renderToStaticMarkup`](https://beta.reactjs.org/reference/react-dom/server/renderToStaticMarkup).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
ReactDOMServer.renderToStaticMarkup(element)
```

25
content/docs/reference-react-dom.md

@ -50,6 +50,10 @@ React supports all modern browsers, although [some polyfills are required](/docs
### `createPortal()` {#createportal}
> Try the new React documentation for [`createPortal`](https://beta.reactjs.org/reference/react-dom/createPortal).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
createPortal(child, container)
```
@ -58,6 +62,10 @@ Creates a portal. Portals provide a way to [render children into a DOM node that
### `flushSync()` {#flushsync}
> Try the new React documentation for [`flushSync`](https://beta.reactjs.org/reference/react-dom/flushSync).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
flushSync(callback)
```
@ -84,6 +92,11 @@ flushSync(() => {
## Legacy Reference {#legacy-reference}
### `render()` {#render}
> Try the new React documentation for [`render`](https://beta.reactjs.org/reference/react-dom/render).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
render(element, container[, callback])
```
@ -114,6 +127,10 @@ If the optional callback is provided, it will be executed after the component is
### `hydrate()` {#hydrate}
> Try the new React documentation for [`hydrate`](https://beta.reactjs.org/reference/react-dom/hydrate).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
hydrate(element, container[, callback])
```
@ -136,6 +153,10 @@ Remember to be mindful of user experience on slow connections. The JavaScript co
### `unmountComponentAtNode()` {#unmountcomponentatnode}
> Try the new React documentation for [`unmountComponentAtNode`](https://beta.reactjs.org/reference/react-dom/unmountComponentAtNode).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
unmountComponentAtNode(container)
```
@ -150,6 +171,10 @@ Remove a mounted React component from the DOM and clean up its event handlers an
### `findDOMNode()` {#finddomnode}
> Try the new React documentation for [`findDOMNode`](https://beta.reactjs.org/reference/react-dom/findDOMNode).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
> Note:
>
> `findDOMNode` is an escape hatch used to access the underlying DOM node. In most cases, use of this escape hatch is discouraged because it pierces the component abstraction. [It has been deprecated in `StrictMode`.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)

56
content/docs/reference-react.md

@ -101,6 +101,10 @@ Suspense lets components "wait" for something before rendering. Today, Suspense
### `React.Component` {#reactcomponent}
> Try the new React documentation for [`Component`](https://beta.reactjs.org/reference/react/Component).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.Component` is the base class for React components when they are defined using [ES6 classes](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes):
```javascript
@ -117,6 +121,10 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o
### `React.PureComponent` {#reactpurecomponent}
> Try the new React documentation for [`PureComponent`](https://beta.reactjs.org/reference/react/PureComponent).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`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.
@ -131,6 +139,10 @@ If your React component's `render()` function renders the same result given the
### `React.memo` {#reactmemo}
> Try the new React documentation for [`memo`](https://beta.reactjs.org/reference/react/memo).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
const MyComponent = React.memo(function MyComponent(props) {
/* render using props */
@ -169,6 +181,10 @@ This method only exists as a **[performance optimization](/docs/optimizing-perfo
### `createElement()` {#createelement}
> Try the new React documentation for [`createElement`](https://beta.reactjs.org/reference/react/createElement).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
React.createElement(
type,
@ -185,6 +201,10 @@ Code written with [JSX](/docs/introducing-jsx.html) will be converted to use `Re
### `cloneElement()` {#cloneelement}
> Try the new React documentation for [`cloneElement`](https://beta.reactjs.org/reference/react/cloneElement).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```
React.cloneElement(
element,
@ -209,6 +229,10 @@ This API was introduced as a replacement of the deprecated `React.addons.cloneWi
### `createFactory()` {#createfactory}
> Try the new React documentation for [`createFactory`](https://beta.reactjs.org/reference/react/createFactory).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
React.createFactory(type)
```
@ -223,6 +247,10 @@ You will not typically invoke `React.createFactory()` directly if you are using
### `isValidElement()` {#isvalidelement}
> Try the new React documentation for [`isValidElement`](https://beta.reactjs.org/reference/react/isValidElement).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```javascript
React.isValidElement(object)
```
@ -233,6 +261,10 @@ Verifies the object is a React element. Returns `true` or `false`.
### `React.Children` {#reactchildren}
> Try the new React documentation for [`Children`](https://beta.reactjs.org/reference/react/Children).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.Children` provides utilities for dealing with the `this.props.children` opaque data structure.
#### `React.Children.map` {#reactchildrenmap}
@ -291,6 +323,10 @@ Returns the `children` opaque data structure as a flat array with keys assigned
### `React.Fragment` {#reactfragment}
> Try the new React documentation for [`Fragment`](https://beta.reactjs.org/reference/react/Fragment).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
The `React.Fragment` component lets you return multiple elements in a `render()` method without creating an additional DOM element:
```javascript
@ -309,11 +345,19 @@ You can also use it with the shorthand `<></>` syntax. For more information, see
### `React.createRef` {#reactcreateref}
> Try the new React documentation for [`createRef`](https://beta.reactjs.org/reference/react/createRef).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.createRef` creates a [ref](/docs/refs-and-the-dom.html) that can be attached to React elements via the ref attribute.
`embed:16-3-release-blog-post/create-ref-example.js`
### `React.forwardRef` {#reactforwardref}
> Try the new React documentation for [`forwardRef`](https://beta.reactjs.org/reference/react/forwardRef).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.forwardRef` creates a React component that forwards the [ref](/docs/refs-and-the-dom.html) attribute it receives to another component below in the tree. This technique is not very common but is particularly useful in two scenarios:
* [Forwarding refs to DOM components](/docs/forwarding-refs.html#forwarding-refs-to-dom-components)
@ -331,6 +375,10 @@ For more information, see [forwarding refs](/docs/forwarding-refs.html).
### `React.lazy` {#reactlazy}
> Try the new React documentation for [`lazy`](https://beta.reactjs.org/reference/react/lazy).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.lazy()` lets you define a component that is loaded dynamically. This helps reduce the bundle size to delay loading components that aren't used during the initial render.
You can learn how to use it from our [code splitting documentation](/docs/code-splitting.html#reactlazy). You might also want to check out [this article](https://medium.com/@pomber/lazy-loading-and-preloading-components-in-react-16-6-804de091c82d) explaining how to use it in more detail.
@ -344,6 +392,10 @@ Note that rendering `lazy` components requires that there's a `<React.Suspense>`
### `React.Suspense` {#reactsuspense}
> Try the new React documentation for [`Suspense`](https://beta.reactjs.org/reference/react/Suspense).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`React.Suspense` lets you specify the loading indicator in case some components in the tree below it are not yet ready to render. In the future we plan to let `Suspense` handle more scenarios such as data fetching. You can read about this in [our roadmap](/blog/2018/11/27/react-16-roadmap.html).
Today, lazy loading components is the **only** use case supported by `<React.Suspense>`:
@ -379,6 +431,10 @@ Suspense boundaries depend on their parent boundaries being hydrated before they
### `React.startTransition` {#starttransition}
> Try the new React documentation for [`startTransition`](https://beta.reactjs.org/reference/react/startTransition).
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
```js
React.startTransition(callback)
```

11
content/docs/refs-and-the-dom.md

@ -11,6 +11,17 @@ redirect_from:
- "tips/children-undefined.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Referencing Values with Refs](https://beta.reactjs.org/learn/referencing-values-with-refs)
> - [Manipulating the DOM with Refs](https://beta.reactjs.org/learn/manipulating-the-dom-with-refs)
> - [`useRef`](https://beta.reactjs.org/reference/react/useRef)
> - [`forwardRef`](https://beta.reactjs.org/reference/react/forwardRef)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
Refs provide a way to access DOM nodes or React elements created in the render method.
In the typical React dataflow, [props](/docs/components-and-props.html) are the only way that parent components interact with their children. To modify a child, you re-render it with new props. However, there are a few cases where you need to imperatively modify a child outside of the typical dataflow. The child to be modified could be an instance of a React component, or it could be a DOM element. For both of these cases, React provides an escape hatch.

9
content/docs/state-and-lifecycle.md

@ -8,6 +8,15 @@ prev: components-and-props.html
next: handling-events.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [State: A Component's Memory](https://beta.reactjs.org/learn/state-a-components-memory)
> - [Synchronizing with Effects](https://beta.reactjs.org/learn/synchronizing-with-effects)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
This page introduces the concept of state and lifecycle in a React component. You can find a [detailed component API reference here](/docs/react-component.html).
Consider the ticking clock example from [one of the previous sections](/docs/rendering-elements.html#updating-the-rendered-element). In [Rendering Elements](/docs/rendering-elements.html#rendering-an-element-into-the-dom), we have only learned one way to update the UI. We call `root.render()` to change the rendered output:

9
content/docs/strict-mode.md

@ -4,6 +4,15 @@ title: Strict Mode
permalink: docs/strict-mode.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [`StrictMode`](https://beta.reactjs.org/reference/react/StrictMode)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
`StrictMode` is a tool for highlighting potential problems in an application. Like `Fragment`, `StrictMode` does not render any visible UI. It activates additional checks and warnings for its descendants.
> Note:

8
content/docs/thinking-in-react.md

@ -8,6 +8,14 @@ redirect_from:
prev: composition-vs-inheritance.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Thinking in React](https://beta.reactjs.org/learn/thinking-in-react)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
React is, in our opinion, the premier way to build big, fast Web apps with JavaScript. It has scaled very well for us at Facebook and Instagram.
One of the many great parts of React is how it makes you think about apps as you build them. In this document, we'll walk you through the thought process of building a searchable product data table using React.

10
content/docs/uncontrolled-components.md

@ -4,6 +4,16 @@ title: Uncontrolled Components
permalink: docs/uncontrolled-components.html
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [`<input>`](https://beta.reactjs.org/reference/react-dom/components/input)
> - [`<select>`](https://beta.reactjs.org/reference/react-dom/components/select)
> - [`<textarea>`](https://beta.reactjs.org/reference/react-dom/components/textarea)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
In most cases, we recommend using [controlled components](/docs/forms.html#controlled-components) to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself.
To write an uncontrolled component, instead of writing an event handler for every state update, you can [use a ref](/docs/refs-and-the-dom.html) to get form values from the DOM.

8
content/tutorial/tutorial.md

@ -12,6 +12,14 @@ redirect_from:
- "docs/tutorial-zh-CN.html"
---
> Try the new React documentation for this topic.
>
> These new documentation pages teach modern React and include live examples:
>
> - [Tutorial: Tic Tac Toe](https://beta.reactjs.org/learn/tutorial-tic-tac-toe)
>
> The new docs will soon replace this site, which will be archived. [Provide feedback here.](https://github.com/reactjs/reactjs.org/issues/3308)
This tutorial doesn't assume any existing React knowledge.
## Before We Start the Tutorial {#before-we-start-the-tutorial}

Loading…
Cancel
Save