Skip to content

bluepeter/jsondiffpatch-react

Folders and files

NameName
Last commit message
Last commit date
Jun 9, 2021
Jul 10, 2023
Jul 10, 2023
Oct 25, 2016
Oct 25, 2016
Oct 25, 2016
Jul 10, 2023
Aug 3, 2020
Oct 25, 2016
Apr 18, 2017
Jul 11, 2023
Dec 1, 2022
Oct 25, 2016
Oct 25, 2016
Oct 25, 2016
Jun 9, 2021

Repository files navigation

jsondiffpatch-react

1. install

npm install jsondiffpatch-react

2. usage

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

<JsonDiffReact
    right: PropTypes.any,
    left: PropTypes.any,
    show: PropTypes.bool,
    annotated: PropTypes.bool,
    tips: PropTypes.any,
    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 (any)

    Displayed in case both elements are identical.

  • objectHash (function)

    Will be passed to jsondiffpatch to improve array comparison performance, as described here. Example:

    <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.

About

Diff & patch JavaScript objects... in React

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published