Skip to content

Commit

Permalink
[18] Add stubs for new API references (#4477)
Browse files Browse the repository at this point in the history
* [18] Add stubs for new API references

* Change order/grouping
  • Loading branch information
rickhanlonii authored Mar 21, 2022
1 parent 0e999bb commit 15050aa
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
62 changes: 62 additions & 0 deletions content/docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ If you're new to Hooks, you might want to check out [the overview](/docs/hooks-o
- [`useImperativeHandle`](#useimperativehandle)
- [`useLayoutEffect`](#uselayouteffect)
- [`useDebugValue`](#usedebugvalue)
- [`useDeferredValue`](#usedeferredvalue)
- [`useTransition`](#usetransition)
- [`useId`](#useid)
- [Library Hooks](#library-hooks)
- [`useSyncExternalStore`](#usesyncexternalstore)
- [`useInsertionEffect`](#useinsertioneffect)

## Basic Hooks {#basic-hooks}

Expand Down Expand Up @@ -508,3 +514,59 @@ For example a custom Hook that returned a `Date` value could avoid calling the `
```js
useDebugValue(date, date => date.toDateString());
```

### `useDeferredValue` {#usedeferredvalue}

```js
const [deferredValue] = useDeferredValue(value);
```

TODO: description

### `useTransition` {#usetransition}

```js
const [isPending, startTransition] = useTransition();
```

TODO: description

### `useId` {#useid}

```js
const id = useId(value);
```

TODO: description

> Note:
>
> TODO: identifierPrefix
## Library Hooks {#library-hooks}

The following Hooks are provided for library authors to integrate libraries deeply into the React model, and are not typically used in application code.

### `useSyncExternalStore` {#usesyncexternalstore}

```js
const state = useSyncExternalStore(subscribe, snapshot);
```

TODO: description

> Note:
>
> TODO: use-sync-external-store/shim
### `useInsertionEffect` {#useinsertioneffect}

```js
useInsertionEffect(didUpdate);
```

TODO: description

> Note:
>
> TODO: no refs
25 changes: 25 additions & 0 deletions content/docs/reference-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ Suspense lets components "wait" for something before rendering. Today, Suspense
- [`React.lazy`](#reactlazy)
- [`React.Suspense`](#reactsuspense)

### Transitions

*Transitions* are a new concurrent feature introduced in React 18. They allow you to mark updates as transitions, which tells React that they can be interrupted and avoid going back to Suspense fallbacks for already visible content.

- [`React.startTransition`](#starttransition)
- [`React.useTransition`](/docs/hooks-reference.html#usetransition)

### Hooks {#hooks}

*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class. Hooks have a [dedicated docs section](/docs/hooks-intro.html) and a separate API reference:
Expand All @@ -81,6 +88,12 @@ Suspense lets components "wait" for something before rendering. Today, Suspense
- [`useImperativeHandle`](/docs/hooks-reference.html#useimperativehandle)
- [`useLayoutEffect`](/docs/hooks-reference.html#uselayouteffect)
- [`useDebugValue`](/docs/hooks-reference.html#usedebugvalue)
- [`useDeferredValue`](/docs/hooks-reference.html#usedeferredvalue)
- [`useTransition`](/docs/hooks-reference.html#usetransition)
- [`useId`](/docs/hooks-reference.html#useid)
- [Library Hooks](/docs/hooks-reference.html#library-hooks)
- [`useSyncExternalStore`](/docs/hooks-reference.html#usesyncexternalstore)
- [`useInsertionEffect`](/docs/hooks-reference.html#useinsertioneffect)

* * *

Expand Down Expand Up @@ -360,3 +373,15 @@ While this is not supported today, in the future we plan to let `Suspense` handl
>Note:
>
>`React.lazy()` and `<React.Suspense>` are not yet supported by `ReactDOMServer`. This is a known limitation that will be resolved in the future.

### `React.startTransition` {#starttransition}

```js
React.startTransition(callback)
```

TODO: description

> Note:
>
> TODO: useTransition

0 comments on commit 15050aa

Please sign in to comment.