Browse Source

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>
main
Sebastian Silbermann 5 years ago
committed by GitHub
parent
commit
9e5a358cb2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      content/docs/strict-mode.md

12
content/docs/strict-mode.md

@ -97,13 +97,13 @@ Render phase lifecycles include the following class component methods:
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).
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:
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:
* Class component `constructor` method
* The `render` method
* `setState` updater functions (the first argument)
* The static `getDerivedStateFromProps` lifecycle
* The `shouldComponentUpdate` method
* Class component `constructor`, `render`, and `shouldComponent` methods
* Class component static `getDerivedStateFromProps` method
* Function component bodies
* State updater functions (the first argument to `setState`)
* Functions passed to `useState`, `useMemo`, or `useReducer`
> Note:
>

Loading…
Cancel
Save