Gathering detailed insights and metrics for react-fast-compare
Gathering detailed insights and metrics for react-fast-compare
Gathering detailed insights and metrics for react-fast-compare
Gathering detailed insights and metrics for react-fast-compare
@react-hookz/deep-equal
Fast deep equal comparator
babel-plugin-react-fast-compare
babel-plugin-react-fast-compare
@luchanso/react-fast-compare
Fastest deep equal comparison for React. Perfect for shouldComponentUpdate. Also really fast general-purpose deep comparison
react-code-compare
A simple and fast text diff viewer component
fastest deep equal comparison for React
npm install react-fast-compare
Typescript
Module System
Node Version
NPM Version
98.7
Supply Chain
100
Quality
83.4
Maintenance
100
Vulnerability
100
License
JavaScript (92.49%)
TypeScript (7.51%)
Total Downloads
2,092,926,481
Last Day
509,847
Last Week
11,120,764
Last Month
48,351,113
Last Year
520,282,971
MIT License
1,642 Stars
157 Commits
56 Forks
45 Watchers
11 Branches
64 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
3.2.2
Package Id
react-fast-compare@3.2.2
Unpacked Size
15.78 kB
Size
6.05 kB
File Count
5
NPM Version
9.5.1
Node Version
18.16.0
Published on
May 18, 2023
Cumulative downloads
Total Downloads
Last Day
-9.7%
509,847
Compared to previous day
Last Week
-7.8%
11,120,764
Compared to previous week
Last Month
2.2%
48,351,113
Compared to previous month
Last Year
5.7%
520,282,971
Compared to previous year
46
The fastest deep equal comparison for React. Very quick general-purpose deep
comparison, too. Great for React.memo
and shouldComponentUpdate
.
This is a fork of the brilliant fast-deep-equal with some extra handling for React.
(Check out the benchmarking details.)
1$ yarn add react-fast-compare 2# or 3$ npm install react-fast-compare
1const isEqual = require("react-fast-compare"); 2 3// general usage 4console.log(isEqual({ foo: "bar" }, { foo: "bar" })); // true 5 6// React.memo 7// only re-render ExpensiveComponent when the props have deeply changed 8const DeepMemoComponent = React.memo(ExpensiveComponent, isEqual); 9 10// React.Component shouldComponentUpdate 11// only re-render AnotherExpensiveComponent when the props have deeply changed 12class AnotherExpensiveComponent extends React.Component { 13 shouldComponentUpdate(nextProps) { 14 return !isEqual(this.props, nextProps); 15 } 16 render() { 17 // ... 18 } 19}
React.memo
(or shouldComponentUpdate
)?What's faster than a really fast deep comparison? No deep comparison at all.
—This Readme
Deep checks in React.memo
or a shouldComponentUpdate
should not be used blindly.
First, see if the default
React.memo or
PureComponent
will work for you. If it won't (if you need deep checks), it's wise to make
sure you've correctly indentified the bottleneck in your application by
profiling the performance.
After you've determined that you do need deep equality checks and you've
identified the minimum number of places to apply them, then this library may
be for you!
The absolute values are much less important than the relative differences between packages.
Benchmarking source can be found here. Each "operation" consists of running all relevant tests. The React benchmark uses both the generic tests and the react tests; these runs will be slower simply because there are more tests in each operation.
The results below are from a local test on a laptop (stats last updated 6/2/2020):
react-fast-compare x 177,600 ops/sec ±1.73% (92 runs sampled)
fast-deep-equal x 184,211 ops/sec ±0.65% (87 runs sampled)
lodash.isEqual x 39,826 ops/sec ±1.32% (86 runs sampled)
nano-equal x 176,023 ops/sec ±0.89% (92 runs sampled)
shallow-equal-fuzzy x 146,355 ops/sec ±0.64% (89 runs sampled)
fastest: fast-deep-equal
react-fast-compare
and fast-deep-equal
should be the same speed for these
tests; any difference is just noise. react-fast-compare
won't be faster than
fast-deep-equal
, because it's based on it.
react-fast-compare x 86,392 ops/sec ±0.70% (93 runs sampled)
fast-deep-equal x 85,567 ops/sec ±0.95% (92 runs sampled)
lodash.isEqual x 7,369 ops/sec ±1.78% (84 runs sampled)
fastest: react-fast-compare,fast-deep-equal
Two of these packages cannot handle comparing React elements, because they
contain circular reference: nano-equal
and shallow-equal-fuzzy
.
1$ yarn install 2$ yarn run benchmark
fast-deep-equal
react-fast-compare
is based on fast-deep-equal
, with some additions:
react-fast-compare
has try
/catch
guardrails for stack overflows from undetected (non-React) circular references.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.This version of react-fast-compare
tracks fast-deep-equal@3.1.1
.
There are a variety of ways to calculate bundle size for JavaScript code.
You can see our size test code in the compress
script in
package.json
.
Bundlephobia's calculation is slightly higher,
as they do not mangle during minification.
Please see our contributions guide.
Active: Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 9/14 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More