From ee1f4167908d42c6a67a51b63ba683789d57c0cf Mon Sep 17 00:00:00 2001 From: Szymon Nowicki Date: Fri, 15 Dec 2017 17:29:55 +0100 Subject: [PATCH 1/4] Update `React.PureComponent` reference. Maybe I'm somehow weird, but I lived for some time with an idea that `React.Component` does implement `shouldComponentUpdate` with deep comparison. `React.PureComponent` is faster because it compares shallowly. The changes I propose should avoid this "implicit" kind of way of thinking, since it would explicitly state that `React.Component` does not compare anything. --- content/docs/reference-react.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index 968d376c7..05b81e014 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -71,9 +71,9 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o ### `React.PureComponent` -`React.PureComponent` is exactly like [`React.Component`](#reactcomponent), but implements [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) with a shallow prop and state comparison. +`React.PureComponent` is exactly like [`React.Component`](#reactcomponent), but implements [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) with a shallow prop and state comparison, which [`React.Component`](#reactcomponent) is missing completely. -If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. +If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. > Note > From 04f46c4c5d4e5eb15355b4ef427e2e6b6eccb27e Mon Sep 17 00:00:00 2001 From: Szymon Nowicki Date: Fri, 15 Dec 2017 17:31:42 +0100 Subject: [PATCH 2/4] Update reference-react.md Rolled back trailing whitespace. --- content/docs/reference-react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index 05b81e014..6320a34ce 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -73,7 +73,7 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o `React.PureComponent` is exactly like [`React.Component`](#reactcomponent), but implements [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) with a shallow prop and state comparison, which [`React.Component`](#reactcomponent) is missing completely. -If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. +If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. > Note > From 74d974449cb9a33178b42106bd52f15d93be784d Mon Sep 17 00:00:00 2001 From: Szymon Nowicki Date: Sat, 16 Dec 2017 12:25:31 +0100 Subject: [PATCH 3/4] Update `React.PureComponent` reference. Rewording the `React.PureComponent` reference to make it more clear, that `React.Component` doesn't implement `.shouldComponentUpdate` at all. --- content/docs/reference-react.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index 6320a34ce..1c9eadf98 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -70,8 +70,7 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o * * * ### `React.PureComponent` - -`React.PureComponent` is exactly like [`React.Component`](#reactcomponent), but implements [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate) with a shallow prop and state comparison, which [`React.Component`](#reactcomponent) is missing completely. +`React.PureComponent` is similar to [`React.Component`](#reactcomponent). The difference between them is that [`React.Component`](#reactcomponent) doesn't implement [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate), but `React.PureComponent` implements it with a shallow prop and state comparison. If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases. From b646c386b841939a93b79b9a2c82bab16933ed20 Mon Sep 17 00:00:00 2001 From: Szymon Nowicki Date: Sat, 16 Dec 2017 12:26:57 +0100 Subject: [PATCH 4/4] Rolled back empty line removal. --- content/docs/reference-react.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index 1c9eadf98..05e09d87e 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -70,6 +70,7 @@ See the [React.Component API Reference](/docs/react-component.html) for a list o * * * ### `React.PureComponent` + `React.PureComponent` is similar to [`React.Component`](#reactcomponent). The difference between them is that [`React.Component`](#reactcomponent) doesn't implement [`shouldComponentUpdate()`](/docs/react-component.html#shouldcomponentupdate), but `React.PureComponent` implements it with a shallow prop and state comparison. If your React component's `render()` function renders the same result given the same props and state, you can use `React.PureComponent` for a performance boost in some cases.