
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
react-fast-compare
Advanced tools
Fastest deep equal comparison for React. Perfect for shouldComponentUpdate. Also really fast general-purpose deep comparison
The fastest deep equal comparison for React, perfect for shouldComponentUpdate, also really fast at general-purpose deep comparison. This is a fork of the brilliant fast-deep-equal with some extra handling for React.
(Check out the benchmarking details.)
yarn add react-fast-compare
# or
npm install react-fast-compare
const isEqual = require('react-fast-compare');
// general usage
console.log(isEqual({foo: 'bar'}, {foo: 'bar'})); // true
// react usage
class ExpensiveRenderer extends React.Component {
shouldComponentUpdate(nextProps) {
return !isEqual(this.props, nextProps);
}
render() {
// ...
}
}
All tests carried out locally on a Macbook. 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.
react-fast-compare x 161,872 ops/sec ±1.18% (82 runs sampled)
fast-deep-equal x 159,889 ops/sec ±1.62% (85 runs sampled)
lodash.isEqual x 30,750 ops/sec ±2.02% (86 runs sampled)
nano-equal x 35,608 ops/sec ±1.55% (86 runs sampled)
shallow-equal-fuzzy x 94,141 ops/sec ±1.80% (89 runs sampled)
fastest: react-fast-compare,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 150,667 ops/sec ±1.86% (83 runs sampled)
fast-deep-equal x 510 ops/sec ±1.67% (77 runs sampled)
lodash.isEqual x 25,760 ops/sec ±1.63% (83 runs sampled)
nano-equal x 629 ops/sec ±2.43% (80 runs sampled)
shallow-equal-fuzzy x 454 ops/sec ±1.42% (79 runs sampled)
fastest: react-fast-compare
Three of these packages cannot handle comparing React elements (which are circular): fast-deep-equal, nano-equal, and shallow-equal-fuzzy.
yarn install
yarn run benchmark
Lodash's isEqual method provides deep comparison of objects and arrays, similar to react-fast-compare. However, lodash is a general utility library that includes a wide range of functions, which may result in a larger bundle size if only isEqual is needed.
The deep-equal package is another library that can perform deep equality checks. It is not specifically optimized for React and may not be as performant as react-fast-compare in the context of comparing React props and state.
fast-deep-equal is a package that offers a fast deep equality comparison. It is similar to react-fast-compare but is not specifically tailored for React, although it can be used in any JavaScript environment.
FAQs
Fastest deep equal comparison for React. Great for React.memo & shouldComponentUpdate. Also really fast general-purpose deep comparison.
The npm package react-fast-compare receives a total of 4,300,567 weekly downloads. As such, react-fast-compare popularity was classified as popular.
We found that react-fast-compare demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 21 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.