From 1442bf4944dee222794bcaa19444613c55fdda4f Mon Sep 17 00:00:00 2001 From: Carlos Cuesta Date: Sat, 7 Oct 2017 10:54:21 +0200 Subject: [PATCH 1/3] Document deepEquality checks & JSON.stringify in scu are a bad idea --- content/docs/reference-react-component.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/docs/reference-react-component.md b/content/docs/reference-react-component.md index a7ee595d..713843ea 100644 --- a/content/docs/reference-react-component.md +++ b/content/docs/reference-react-component.md @@ -206,6 +206,8 @@ Currently, if `shouldComponentUpdate()` returns `false`, then [`componentWillUpd If you determine a specific component is slow after profiling, you may change it to inherit from [`React.PureComponent`](/docs/react-api.html#react.purecomponent) which implements `shouldComponentUpdate()` with a shallow prop and state comparison. If you are confident you want to write it by hand, you may compare `this.props` with `nextProps` and `this.state` with `nextState` and return `false` to tell React the update can be skipped. +We do not recommend doing deep equality checks and using `JSON.stringify()` in `shouldComponentUpdate()`. It is very inefficient and a really bad idea for performance. + * * * ### `componentWillUpdate()` From b785e8f7a5e441b15af50c89ab7e0014919cdc50 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 18 Oct 2017 08:56:40 -0700 Subject: [PATCH 2/3] Changed "and" to "or" --- content/docs/reference-react-component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/reference-react-component.md b/content/docs/reference-react-component.md index 713843ea..21c9eb8d 100644 --- a/content/docs/reference-react-component.md +++ b/content/docs/reference-react-component.md @@ -206,7 +206,7 @@ Currently, if `shouldComponentUpdate()` returns `false`, then [`componentWillUpd If you determine a specific component is slow after profiling, you may change it to inherit from [`React.PureComponent`](/docs/react-api.html#react.purecomponent) which implements `shouldComponentUpdate()` with a shallow prop and state comparison. If you are confident you want to write it by hand, you may compare `this.props` with `nextProps` and `this.state` with `nextState` and return `false` to tell React the update can be skipped. -We do not recommend doing deep equality checks and using `JSON.stringify()` in `shouldComponentUpdate()`. It is very inefficient and a really bad idea for performance. +We do not recommend doing deep equality checks or using `JSON.stringify()` in `shouldComponentUpdate()`. It is very inefficient and a really bad idea for performance. * * * From 07b015b6871186659a8d8ee786dc653ed7ca3c38 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 18 Oct 2017 08:57:59 -0700 Subject: [PATCH 3/3] Wording nit --- content/docs/reference-react-component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/reference-react-component.md b/content/docs/reference-react-component.md index 21c9eb8d..445a5593 100644 --- a/content/docs/reference-react-component.md +++ b/content/docs/reference-react-component.md @@ -206,7 +206,7 @@ Currently, if `shouldComponentUpdate()` returns `false`, then [`componentWillUpd If you determine a specific component is slow after profiling, you may change it to inherit from [`React.PureComponent`](/docs/react-api.html#react.purecomponent) which implements `shouldComponentUpdate()` with a shallow prop and state comparison. If you are confident you want to write it by hand, you may compare `this.props` with `nextProps` and `this.state` with `nextState` and return `false` to tell React the update can be skipped. -We do not recommend doing deep equality checks or using `JSON.stringify()` in `shouldComponentUpdate()`. It is very inefficient and a really bad idea for performance. +We do not recommend doing deep equality checks or using `JSON.stringify()` in `shouldComponentUpdate()`. It is very inefficient and will harm performance. * * *