From 9e5a358cb24a665fc48615ae224f26a4f2191b32 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 30 Mar 2020 16:01:54 +0200 Subject: [PATCH] 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 --- content/docs/strict-mode.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index 0f48ba161..a26f04d82 100644 --- a/content/docs/strict-mode.md +++ b/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: >