{"id":15039453,"url":"https://github.com/formidablelabs/react-fast-compare","last_synced_at":"2025-05-13T23:05:27.133Z","repository":{"id":39379955,"uuid":"128978936","full_name":"FormidableLabs/react-fast-compare","owner":"FormidableLabs","description":"fastest deep equal comparison for React","archived":false,"fork":false,"pushed_at":"2024-03-20T20:11:52.000Z","size":2150,"stargazers_count":1638,"open_issues_count":12,"forks_count":56,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-05-07T20:03:46.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FormidableLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-10T18:33:39.000Z","updated_at":"2025-05-07T11:16:52.000Z","dependencies_parsed_at":"2023-02-15T08:01:46.261Z","dependency_job_id":"2532465f-6049-4041-9774-56afb1ceb55b","html_url":"https://github.com/FormidableLabs/react-fast-compare","commit_stats":{"total_commits":135,"total_committers":32,"mean_commits":4.21875,"dds":0.7851851851851852,"last_synced_commit":"6f7d8afe02e4480c32f5af16f571367cccd47abc"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-fast-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-fast-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-fast-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Freact-fast-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FormidableLabs","download_url":"https://codeload.github.com/FormidableLabs/react-fast-compare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254040676,"owners_count":22004592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T20:42:53.663Z","updated_at":"2025-05-13T23:05:22.105Z","avatar_url":"https://github.com/FormidableLabs.png","language":"JavaScript","readme":"[![React Fast Compare — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/react-fast-compare/master/react-fast-compare-Hero.png)](https://formidable.com/open-source/)\n\n[![Downloads][downloads_img]][npm_site]\n[![Bundle Size][bundle_img]](#bundle-size)\n[![GH Actions Status][actions_img]][actions_site]\n[![Coverage Status][cov_img]][cov_site]\n[![npm version][npm_img]][npm_site]\n[![Maintenance Status][maintenance_img]](#maintenance-status)\n\nThe fastest deep equal comparison for React. Very quick general-purpose deep\ncomparison, too. Great for `React.memo` and `shouldComponentUpdate`.\n\nThis is a fork of the brilliant\n[fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal) with some\nextra handling for React.\n\n![benchmark chart](https://raw.githubusercontent.com/FormidableLabs/react-fast-compare/master/assets/benchmarking.png \"benchmarking chart\")\n\n(Check out the [benchmarking details](#benchmarking-this-library).)\n\n## Install\n\n```sh\n$ yarn add react-fast-compare\n# or\n$ npm install react-fast-compare\n```\n\n## Highlights\n\n- ES5 compatible; works in node.js (0.10+) and browsers (IE9+)\n- deeply compares any value (besides objects with circular references)\n- handles React-specific circular references, like elements\n- checks equality Date and RegExp objects\n- should be as fast as [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal) via a single unified library, and with added guardrails for circular references.\n- small: under 660 bytes minified+gzipped\n\n## Usage\n\n```jsx\nconst isEqual = require(\"react-fast-compare\");\n\n// general usage\nconsole.log(isEqual({ foo: \"bar\" }, { foo: \"bar\" })); // true\n\n// React.memo\n// only re-render ExpensiveComponent when the props have deeply changed\nconst DeepMemoComponent = React.memo(ExpensiveComponent, isEqual);\n\n// React.Component shouldComponentUpdate\n// only re-render AnotherExpensiveComponent when the props have deeply changed\nclass AnotherExpensiveComponent extends React.Component {\n  shouldComponentUpdate(nextProps) {\n    return !isEqual(this.props, nextProps);\n  }\n  render() {\n    // ...\n  }\n}\n```\n\n## Do I Need `React.memo` (or `shouldComponentUpdate`)?\n\n\u003e What's faster than a really fast deep comparison? No deep comparison at all.\n\n—This Readme\n\nDeep checks in `React.memo` or a `shouldComponentUpdate` should not be used blindly.\nFirst, see if the default\n[React.memo](https://reactjs.org/docs/react-api.html#reactmemo) or\n[PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)\nwill work for you. If it won't (if you need deep checks), it's wise to make\nsure you've correctly indentified the bottleneck in your application by\n[profiling the performance](https://reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab).\nAfter you've determined that you _do_ need deep equality checks and you've\nidentified the minimum number of places to apply them, then this library may\nbe for you!\n\n## Benchmarking this Library\n\nThe absolute values are much less important than the relative differences\nbetween packages.\n\nBenchmarking source can be found\n[here](https://github.com/FormidableLabs/react-fast-compare/blob/master/benchmark/index.js).\nEach \"operation\" consists of running all relevant tests. The React benchmark\nuses both the generic tests and the react tests; these runs will be slower\nsimply because there are more tests in each operation.\n\nThe results below are from a local test on a laptop _(stats last updated 6/2/2020)_:\n\n### Generic Data\n\n```\nreact-fast-compare x 177,600 ops/sec ±1.73% (92 runs sampled)\nfast-deep-equal x 184,211 ops/sec ±0.65% (87 runs sampled)\nlodash.isEqual x 39,826 ops/sec ±1.32% (86 runs sampled)\nnano-equal x 176,023 ops/sec ±0.89% (92 runs sampled)\nshallow-equal-fuzzy x 146,355 ops/sec ±0.64% (89 runs sampled)\n  fastest: fast-deep-equal\n```\n\n`react-fast-compare` and `fast-deep-equal` should be the same speed for these\ntests; any difference is just noise. `react-fast-compare` won't be faster than\n`fast-deep-equal`, because it's based on it.\n\n### React and Generic Data\n\n```\nreact-fast-compare x 86,392 ops/sec ±0.70% (93 runs sampled)\nfast-deep-equal x 85,567 ops/sec ±0.95% (92 runs sampled)\nlodash.isEqual x 7,369 ops/sec ±1.78% (84 runs sampled)\n  fastest: react-fast-compare,fast-deep-equal\n```\n\nTwo of these packages cannot handle comparing React elements, because they\ncontain circular reference: `nano-equal` and `shallow-equal-fuzzy`.\n\n### Running Benchmarks\n\n```sh\n$ yarn install\n$ yarn run benchmark\n```\n\n## Differences between this library and `fast-deep-equal`\n\n`react-fast-compare` is based on `fast-deep-equal`, with some additions:\n\n- `react-fast-compare` has `try`/`catch` guardrails for stack overflows from undetected (non-React) circular references.\n- `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.\n\nThis version of `react-fast-compare` tracks `fast-deep-equal@3.1.1`.\n\n## Bundle Size\n\nThere are a variety of ways to calculate bundle size for JavaScript code.\nYou can see our size test code in the `compress` script in\n[`package.json`](https://github.com/FormidableLabs/react-fast-compare/blob/master/package.json).\n[Bundlephobia's calculation](https://bundlephobia.com/result?p=react-fast-compare) is slightly higher,\nas they [do not mangle during minification](https://github.com/pastelsky/package-build-stats/blob/v6.1.1/src/getDependencySizeTree.js#L139).\n\n## License\n\n[MIT](https://github.com/FormidableLabs/react-fast-compare/blob/readme/LICENSE)\n\n## Contributing\n\nPlease see our [contributions guide](./CONTRIBUTING.md).\n\n## Maintenance Status\n\n**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.\n\n[actions_img]: https://github.com/FormidableLabs/react-fast-compare/actions/workflows/ci.yml/badge.svg\n[actions_site]: https://github.com/formidablelabs/react-fast-compare/actions/workflows/ci.yml\n[cov_img]: https://codecov.io/gh/FormidableLabs/react-fast-compare/branch/master/graph/badge.svg\n[cov_site]: https://codecov.io/gh/FormidableLabs/react-fast-compare\n[npm_img]: https://badge.fury.io/js/react-fast-compare.svg\n[npm_site]: http://badge.fury.io/js/react-fast-compare\n[appveyor_img]: https://ci.appveyor.com/api/projects/status/github/formidablelabs/react-fast-compare?branch=master\u0026svg=true\n[appveyor_site]: https://ci.appveyor.com/project/FormidableLabs/react-fast-compare\n[bundle_img]: https://img.shields.io/badge/minzipped%20size-656%20B-flatgreen.svg\n[downloads_img]: https://img.shields.io/npm/dm/react-fast-compare.svg\n[maintenance_img]: https://img.shields.io/badge/maintenance-active-flatgreen.svg\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformidablelabs%2Freact-fast-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fformidablelabs%2Freact-fast-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformidablelabs%2Freact-fast-compare/lists"}