From c4521eff111d027ea141db8b7c8da802d0acbfd7 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 29 Oct 2019 13:12:46 +0100 Subject: [PATCH 1/5] Update strict-mode.md --- content/docs/strict-mode.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index e803a32d45e..7110bc99501 100644 --- a/content/docs/strict-mode.md +++ b/content/docs/strict-mode.md @@ -100,9 +100,12 @@ Because the above methods might be called more than once, it's important that th 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: * Class component `constructor` method -* The `render` method -* `setState` updater functions (the first argument) +* The `render` method of class components or the function component itself +* state updater functions (the first argument for the `setState` class component method or the argument for the `setState` return value of [`useState`](hooks-reference.html#usestate)) * The static `getDerivedStateFromProps` lifecycle +* the function passed as the initial state to [`useState`](hooks-reference.html#lazy-initial-state) +* the `init` function passed to [`useReducer`](/hooks-reference.html#usereducer) +* "create" functions passed to [`useMemo`](https://reactjs.org/docs/hooks-reference.html#usememo) > Note: > From d777c533843e7bb54359d5bbd7b09dc2ecf21f4a Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 29 Oct 2019 13:36:24 +0100 Subject: [PATCH 2/5] Fix links --- content/docs/strict-mode.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index 7110bc99501..b00a7e0437c 100644 --- a/content/docs/strict-mode.md +++ b/content/docs/strict-mode.md @@ -104,8 +104,8 @@ Strict mode can't automatically detect side effects for you, but it can help you * state updater functions (the first argument for the `setState` class component method or the argument for the `setState` return value of [`useState`](hooks-reference.html#usestate)) * The static `getDerivedStateFromProps` lifecycle * the function passed as the initial state to [`useState`](hooks-reference.html#lazy-initial-state) -* the `init` function passed to [`useReducer`](/hooks-reference.html#usereducer) -* "create" functions passed to [`useMemo`](https://reactjs.org/docs/hooks-reference.html#usememo) +* the `init` function passed to [`useReducer`](hooks-reference.html#usereducer) +* "create" functions passed to [`useMemo`](hooks-reference.html#usememo) > Note: > From 89d1555a607ef47e21f4d15c7980f7c4c6ec253b Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 29 Mar 2020 10:56:26 +0200 Subject: [PATCH 3/5] docs: specify which kind of function component --- content/docs/strict-mode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index bbe679b1e43..214b9ace7c1 100644 --- a/content/docs/strict-mode.md +++ b/content/docs/strict-mode.md @@ -100,7 +100,7 @@ Because the above methods might be called more than once, it's important that th 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: * Class component `constructor` method -* The `render` method of class components or the function component itself +* The `render` method of class components or the function component itself **only if** it uses [Hooks](hooks-intro.html) * state updater functions (the first argument for the `setState` class component method or the argument for the `setState` return value of [`useState`](hooks-reference.html#usestate)) * The static `getDerivedStateFromProps` lifecycle * The `shouldComponentUpdate` method From f1ac7052ef87f5c59c07e0bdd2a8a91ab7fd6a8c Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 29 Mar 2020 18:59:50 +0200 Subject: [PATCH 4/5] Update content/docs/strict-mode.md --- content/docs/strict-mode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index 214b9ace7c1..2b59396c05f 100644 --- a/content/docs/strict-mode.md +++ b/content/docs/strict-mode.md @@ -100,7 +100,7 @@ Because the above methods might be called more than once, it's important that th 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: * Class component `constructor` method -* The `render` method of class components or the function component itself **only if** it uses [Hooks](hooks-intro.html) +* The `render` method of class components or the function component itself * state updater functions (the first argument for the `setState` class component method or the argument for the `setState` return value of [`useState`](hooks-reference.html#usestate)) * The static `getDerivedStateFromProps` lifecycle * The `shouldComponentUpdate` method From b4b1e99ccf342072be1a66ec1d233a0e9cd6bd45 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 30 Mar 2020 15:01:46 +0100 Subject: [PATCH 5/5] Update strict-mode.md --- content/docs/strict-mode.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/content/docs/strict-mode.md b/content/docs/strict-mode.md index 2b59396c05f..a26f04d82bc 100644 --- a/content/docs/strict-mode.md +++ b/content/docs/strict-mode.md @@ -97,16 +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: - -* Class component `constructor` method -* The `render` method of class components or the function component itself -* state updater functions (the first argument for the `setState` class component method or the argument for the `setState` return value of [`useState`](hooks-reference.html#usestate)) -* The static `getDerivedStateFromProps` lifecycle -* The `shouldComponentUpdate` method -* the function passed as the initial state to [`useState`](hooks-reference.html#lazy-initial-state) -* the `init` function passed to [`useReducer`](hooks-reference.html#usereducer) -* "create" functions passed to [`useMemo`](hooks-reference.html#usememo) +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`, `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: >