Browse Source

[Beta] useEffect API (#5103)

* [Beta] useEffect API

* tweaks

* tweak

* add a link

* wip

* keep guide stuff to guides

* moar

* meh
main
dan 2 years ago
committed by GitHub
parent
commit
8ae813f05c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1847
      beta/src/content/apis/react/useEffect.md
  2. 2
      beta/src/content/learn/synchronizing-with-effects.md
  3. 8
      beta/src/sidebarReference.json

1847
beta/src/content/apis/react/useEffect.md

File diff suppressed because it is too large

2
beta/src/content/learn/synchronizing-with-effects.md

@ -590,7 +590,7 @@ Now you get three console logs in development:
React intentionally remounts your components in development to help you find bugs like in the last example. **The right question isn't "how to run an Effect once", but "how to fix my Effect so that it works after remounting".**
Usually, the answer is to implement the cleanup function. The cleanup function should stop or undo whatever the Effect was doing. The rule of thumb is that the user shouldn't be able to distinguish between the Effect running once (as in production) and an _effect → cleanup → effect_ sequence (as you'd see in development).
Usually, the answer is to implement the cleanup function. The cleanup function should stop or undo whatever the Effect was doing. The rule of thumb is that the user shouldn't be able to distinguish between the Effect running once (as in production) and a _setup → cleanup → setup_ sequence (as you'd see in development).
Most of the Effects you'll write will fit into one of the common patterns below.

8
beta/src/sidebarReference.json

@ -105,8 +105,7 @@
},
{
"title": "useEffect",
"path": "/apis/react/useEffect",
"wip": true
"path": "/apis/react/useEffect"
},
{
"title": "useEvent",
@ -128,6 +127,11 @@
"path": "/apis/react/useInsertionEffect",
"wip": true
},
{
"title": "useLayoutEffect",
"path": "/apis/react/useLayoutEffect",
"wip": true
},
{
"title": "useMemo",
"path": "/apis/react/useMemo"

Loading…
Cancel
Save