1.0.4 • Published 4 years ago

jsondiffpatch-for-react v1.0.4

Weekly downloads
578
License
MIT
Repository
github
Last release
4 years ago

jsondiffpatch-for-react

Based on https://github.com/benjamine/jsondiffpatch

1. install

npm install jsondiffpatch-for-react

2. usage

import React from 'react';
import JsonDiffReact from 'jsondiffpatch-for-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. Example:

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

4 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago