Skip to content

Commit 09c5266

Browse files
authored
[WIP] Release V3 (#56)
* fix typos * clarify differences between fast-deep-equal * add React.memo docs * clarify benchmarking * changelog: make breaking changes more specific
1 parent 61b9ec5 commit 09c5266

2 files changed

Lines changed: 35 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# Changelog
22

3-
## UNRELEASED
3+
## 3.0.0 (2020-01-31)
44

55
**Features:**
6-
- Update library to include ES.next support for `Map`, `Set`, `ArrayBuffer`. [#36](https://github.com/FormidableLabs/react-fast-compare/pull/36).
6+
7+
- [#36](https://github.com/FormidableLabs/react-fast-compare/pull/36). Update to `fast-deep-equal@3.1.1` with modified support for ES.next data types: `Map`, `Set`, `ArrayBuffer`.
78

89
**Breaking changes:**
9-
- Update to `fast-deep-equal@3.1.1` with modified support for ES.next data types.
10+
11+
- instances of different classes are now considered unequal
12+
- support for ES6 Map and Set instances
13+
- support for ES6 typed arrays
1014

1115
**Infrastructure:**
16+
1217
- Upgrade lots of `devDependenices`
1318
- Use `fast-deep-equal` tests directly in our correctness tests.
1419
- Update CI to modern Node.js versions.
@@ -38,6 +43,7 @@
3843
- [#21](https://github.com/FormidableLabs/react-fast-compare/pull/21). Upgrade to `fast-deep-equal@2.0.1`. Thanks @samwhale!
3944

4045
**Breaking changes:**
46+
4147
- `null` and `Object` comparison
4248
- new behavior: functions are no longer treated as equal
4349
- new behavior: handle `NaN`

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
[![npm version][npm_img]][npm_site]
88
[![Maintenance Status][maintenance-image]](#maintenance-status)
99

10-
The fastest deep equal comparison for React. Really fast general-purpose deep comparison.
11-
Great for `shouldComponentUpdate`. This is a fork of the brilliant
10+
The fastest deep equal comparison for React. Very quick general-purpose deep
11+
comparison, too. Great for `React.memo` and `shouldComponentUpdate`.
12+
13+
This is a fork of the brilliant
1214
[fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal) with some
1315
extra handling for React.
1416

@@ -41,8 +43,13 @@ const isEqual = require("react-fast-compare");
4143
// general usage
4244
console.log(isEqual({ foo: "bar" }, { foo: "bar" })); // true
4345

44-
// react usage
45-
class ExpensiveRenderer extends React.Component {
46+
// React.memo
47+
// only re-render ExpensiveComponent when the props have deeply changed
48+
const DeepMemoComponent = React.memo(ExpensiveComponent, isEqual);
49+
50+
// React.Component shouldComponentUpdate
51+
// only re-render AnotherExpensiveComponent when the props have deeply changed
52+
class AnotherExpensiveComponent extends React.Component {
4653
shouldComponentUpdate(nextProps) {
4754
return !isEqual(this.props, nextProps);
4855
}
@@ -52,35 +59,36 @@ class ExpensiveRenderer extends React.Component {
5259
}
5360
```
5461

55-
## Do I Need `shouldComponentUpdate`?
62+
## Do I Need `React.memo` (or `shouldComponentUpdate`)?
5663

5764
> What's faster than a really fast deep comparison? No deep comparison at all.
5865
5966
—This Readme
6067

61-
Deep checks in React's `shouldComponentUpdate` should not be used blindly.
62-
First, see if a
68+
Deep checks in `React.memo` or a `shouldComponentUpdate` should not be used blindly.
69+
First, see if the default
70+
[React.memo](https://reactjs.org/docs/react-api.html#reactmemo) or
6371
[PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
64-
would work for you. If it won't (if you need deep checks), it's wise to make
72+
will work for you. If it won't (if you need deep checks), it's wise to make
6573
sure you've correctly indentified the bottleneck in your application by
6674
[profiling the performance](https://reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab).
6775
After you've determined that you _do_ need deep equality checks and you've
6876
identified the minimum number of places to apply them, then this library may
69-
be for you! For more information about making your app faster, check out the
70-
[Optimizing Performance](https://reactjs.org/docs/optimizing-performance.html)
71-
section of the React docs.
77+
be for you!
7278

7379
## Benchmarking this Library
7480

75-
All tests carried out locally on a MacBook. The absolute values are much less
76-
important than the relative differences between packages.
81+
The absolute values are much less important than the relative differences
82+
between packages.
7783

7884
Benchmarking source can be found
7985
[here](https://github.com/FormidableLabs/react-fast-compare/blob/master/benchmark/index.js).
8086
Each "operation" consists of running all relevant tests. The React benchmark
8187
uses both the generic tests and the react tests; these runs will be slower
8288
simply because there are more tests in each operation.
8389

90+
The results below are from a local test on a laptop.
91+
8492
### Generic Data
8593

8694
```
@@ -115,14 +123,14 @@ $ yarn install
115123
$ yarn run benchmark
116124
```
117125

118-
## fast-deep-equal Versioning
126+
## Differences between this library and `fast-deep-equal`
119127

120-
react-fast-compare@3 tracks fast-deep-equal@3.1.1
128+
`react-fast-compare` is based on `fast-deep-equal`, with some additions:
121129

122-
Now that `fast-deep-equal` has separate es5, es6, and es6 + React entry points, the main differences with this library are:
130+
- `react-fast-compare` has `try`/`catch` guardrails for stack overflows from undetected (non-React) circular references.
131+
- `react-fast-compare` has a _single_ unified entry point for all uses. No matter what your target application is, `import equal from 'react-fast-compare'` just works. `fast-deep-equal` has multiple entry points for different use cases.
123132

124-
- `try/catch` guardrails for stack overflows from undetected circular references.
125-
- A single unified entry point for **all** uses. No matter what your target application is, `import equal from 'react-fast-compare'` just works.
133+
This version of `react-fast-compare` tracks `fast-deep-equal@3.1.1`.
126134

127135
## License
128136

0 commit comments

Comments
 (0)