Skip to content

Commit 9e5a358

Browse files
eps1longaearon
andauthored
Explain how StrictMode affects function components and hooks (#2515)
* Update strict-mode.md * Fix links * docs: specify which kind of function component * Update content/docs/strict-mode.md * Update strict-mode.md Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
1 parent c2eb543 commit 9e5a358

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

content/docs/strict-mode.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ Render phase lifecycles include the following class component methods:
9797

9898
Because the above methods might be called more than once, it's important that they do not contain side-effects. Ignoring this rule can lead to a variety of problems, including memory leaks and invalid application state. Unfortunately, it can be difficult to detect these problems as they can often be [non-deterministic](https://en.wikipedia.org/wiki/Deterministic_algorithm).
9999

100-
Strict mode can't automatically detect side effects for you, but it can help you spot them by making them a little more deterministic. This is done by intentionally double-invoking the following methods:
100+
Strict mode can't automatically detect side effects for you, but it can help you spot them by making them a little more deterministic. This is done by intentionally double-invoking the following functions:
101101

102-
* Class component `constructor` method
103-
* The `render` method
104-
* `setState` updater functions (the first argument)
105-
* The static `getDerivedStateFromProps` lifecycle
106-
* The `shouldComponentUpdate` method
102+
* Class component `constructor`, `render`, and `shouldComponent` methods
103+
* Class component static `getDerivedStateFromProps` method
104+
* Function component bodies
105+
* State updater functions (the first argument to `setState`)
106+
* Functions passed to `useState`, `useMemo`, or `useReducer`
107107

108108
> Note:
109109
>

0 commit comments

Comments
 (0)