# jsondiffpatch-react

> jsondiffpatch react

Latest version **1.0.8** (published 2023-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsondiffpatch-react
pnpm add jsondiffpatch-react
yarn add jsondiffpatch-react
bun add jsondiffpatch-react
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2023-07-10 |
| First published | 2021-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 17.7 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | bluepeter |
| Maintainers | bluepeter |
| Keywords | react, json, diff |

## Links

- npm: https://www.npmjs.com/package/jsondiffpatch-react
- Repository: https://github.com/bluepeter/jsondiffpatch-react
- Homepage: https://github.com/bluepeter/jsondiffpatch-react#readme
- Issues: https://github.com/bluepeter/jsondiffpatch-react/issues
- npm.io page: https://npm.io/package/jsondiffpatch-react

## Dependencies (2)

- [yarn.lock](https://npm.io/package/yarn.lock.md) ^0.0.1-security
- [jsondiffpatch](https://npm.io/package/jsondiffpatch.md) ^0.4.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.8 (latest) — 2023-07-10
- 1.0.7 — 2022-12-01
- 1.0.6 — 2021-06-09
- 1.0.5 — 2021-06-09

## README

# jsondiffpatch-react

- Originally forked from archived
  https://github.com/hero-guo/jsondiffpatch-for-react
- Based on https://github.com/benjamine/jsondiffpatch

# 1. install

    npm install jsondiffpatch-react

# 2. usage

```jsx
import React from 'react';
import JsonDiffReact from 'jsondiffpatch-react';

<JsonDiffReact
    right: PropTypes.any,
    left: PropTypes.any,
    show: PropTypes.bool,
    annotated: PropTypes.bool,
    tips: PropTypes.string,
    objectHash: PropTypes.func,
/>
```

# 3. component props

- `left` (array, object, string)

- `right` (array, object, string)

- `show` (bool)

  you can show/hide unchanged values

- `annotated` (bool)

  This will render the original JSON delta in html, with annotations aside
  explaining the meaning of each part. This attempts to make the JSON delta
  format self-explained.

- `tips` (string)

  Message that will displayed in case both elements are identical.

- `objectHash` (function)

  Will be passed to _jsondiffpatch_ to improve array comparison performance, as
  described
  [here](https://github.com/benjamine/jsondiffpatch/blob/master/docs/arrays.md#an-example-using-objecthash).
  Example:

  ```jsx
  <JsonDiffReact
    left={left}
    right={right}
    objectHash={(obj: any) =>
      obj.id || obj._id || obj.name || JSON.stringify(obj)
    }
  />
  ```

# Development notes

To publish to NPM, change the version number in `package.json` and `npm publish`
once complete. Then, go to Github Releases and follow the instructions to
publish a new version there too.

---
_Source: https://npm.io/package/jsondiffpatch-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
