React equivalent of angular-object-diff
npm install react-json-differnpm i react-json-differ
js
import { JsonDifferComponent } from 'react-json-differ'
`
usage
`jsx
`
css
If you want to use the default style for this component :
`js
import "react-json-differ/dist/style.css";
`
Otherwise, these are all the class used that you can override:
`
.reactJsonDiffer__deleted
.reactJsonDiffer__updated
.reactJsonDiffer__added
.reactJsonDiffer__container
.reactJsonDiffer__level
`
Examples
`json
First object:
{prop1: 1, prop2: 2, table:[1,2,3,4]}
`
Second object:
`json
{prop1: 3, prop3: 4, table:[1,2,5,3]}
`

`json
First object:
{
clients: [
{name: "Thor", commands:"Thunder", locations:["Asgärd", "Earth"]},
{name: "Odin", locations:["Asgärd"]}
]
}
Second object:
{
clients: [
{name: "Thor", commands:["Thunder", "clouds"], locations:["Earth", "Yggdrasil"]},
{name: "Odin", locations:["Asgärd"]},
{name: "Loki"}
]
};
`

Caveats and a few more details :
This is not a perfect packages notably when showing differences on update: as you can see on the previous example, we replaced commands:"Thunder" with commands:["Thunder", "clouds"]` and the difference shown doesn't show this easily at first glance.