Code Monkey home page Code Monkey logo

react-deep-diff's Introduction

react-deep-diff

NPM License Downloads

React component to show diff between two objects.

👉🏻 Demo.

demo

Installation

$ yarn add react-deep-diff

Usage

import { DeepDiff } from 'react-deep-diff';

function App() {
  return <DeepDiff className="my-diff" obj1={obj1} obj2={obj2} />;
}

react-deep-diff's People

Contributors

gera2ld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-deep-diff's Issues

两个体验问题

null 变成了空字符串

image

相同对象处理

大段的相同文案,最好自动折叠,点击展开

最后一个问题,位置移动可以识别为移动么?这个可能比较麻烦,不支持也无所谓,可以有空的时候优化一下

测试数据

object 1

{
    "hierarchy": {
        "root": "root",
        "structure": {
            "root": [
                "i18n_2068",
                "download-bar_2072",
                "meta_2070",
                "main-image_2071",
                "elevator_2076",
                "banner_2077",
                "detail-info_2073",
                "margin-line_2075",
                "detail-freight_2078",
                "margin-line_2079",
                "detail-footer_2081",
                "gdpr_2082",
                "seller-invite_2083",
                "action-bar_2084"
            ],
            "detail-info_2073": [
                "discount_2094",
                "split-line_2095",
                "sku_2097",
                "split-line_2098",
                "specifications_2099"
            ],
            "detail-freight_2078": [
                "freight_2100",
                "split-line_2101",
                "service_2102"
            ],
            "detail-footer_2081": [
                "social_2107",
                "recommend_2109",
                "platform-recommend_2108",
                "cross-link_2110"
            ]
        }
    },
    "data": {
        "root": {
            "id": 2063,
            "type": "root",
            "faas": null
        },
        "i18n_2068": {
            "id": 2068,
            "type": "i18n",
            "faas": "i18n"
        },
        "meta_2070": {
            "id": 2070,
            "type": "meta",
            "faas": "meta"
        },
        "main-image_2071": {
            "id": 2071,
            "type": "main-image",
            "faas": "main-image"
        },
        "download-bar_2072": {
            "id": 2072,
            "type": "download-bar",
            "faas": "download-bar"
        },
        "detail-info_2073": {
            "id": 2073,
            "type": "detail-info",
            "faas": null
        },
        "margin-line_2075": {
            "id": 2075,
            "type": "margin-line",
            "faas": null
        },
        "elevator_2076": {
            "id": 2076,
            "type": "elevator",
            "faas": null
        },
        "banner_2077": {
            "id": 2077,
            "type": "banner",
            "faas": "banner"
        },
        "detail-freight_2078": {
            "id": 2078,
            "type": "detail-freight",
            "faas": null
        },
        "margin-line_2079": {
            "id": 2079,
            "type": "margin-line",
            "faas": null
        },
        "detail-footer_2081": {
            "id": 2081,
            "type": "detail-footer",
            "faas": null
        },
        "gdpr_2082": {
            "id": 2082,
            "type": "gdpr",
            "faas": null
        },
        "seller-invite_2083": {
            "id": 2083,
            "type": "seller-invite",
            "faas": "seller-invite"
        },
        "action-bar_2084": {
            "id": 2084,
            "type": "action-bar",
            "faas": "action-bar"
        },
        "discount_2094": {
            "id": 2094,
            "type": "discount",
            "faas": "discount"
        },
        "split-line_2095": {
            "id": 2095,
            "type": "split-line",
            "faas": null
        },
        "sku_2097": {
            "id": 2097,
            "type": "sku",
            "faas": "sku"
        },
        "split-line_2098": {
            "id": 2098,
            "type": "split-line",
            "faas": null
        },
        "specifications_2099": {
            "id": 2099,
            "type": "specifications",
            "faas": "specifications"
        },
        "freight_2100": {
            "id": 2100,
            "type": "freight",
            "faas": "freight"
        },
        "split-line_2101": {
            "id": 2101,
            "type": "split-line",
            "faas": null
        },
        "service_2102": {
            "id": 2102,
            "type": "service",
            "faas": "service"
        },
        "social_2107": {
            "id": 2107,
            "type": "social",
            "faas": null
        },
        "platform-recommend_2108": {
            "id": 2108,
            "type": "platform-recommend",
            "faas": "platform-recommend"
        },
        "recommend_2109": {
            "id": 2109,
            "type": "recommend",
            "faas": null
        },
        "cross-link_2110": {
            "id": 2110,
            "type": "cross-link",
            "faas": "cross-link"
        }
    }
}

object2

{
    "hierarchy": {
        "root": "root",
        "structure": {
            "root": [
                "i18n_2068",
                "meta_2070",
                "download-bar_2072",
                "main-image_2071",
                "banner_2077",
                "elevator_2076",
                "detail-title_2074",
                "detail-info_2073",
                "margin-line_2075",
                "detail-freight_2078",
                "margin-line_2079",
                "detail-other_2080",
                "detail-footer_2081",
                "gdpr_2082",
                "seller-invite_2083",
                "action-bar_2084"
            ],
            "detail-title_2074": [
                "price_2085",
                "vat_2086",
                "plus_2087",
                "biz-mind_2088",
                "title_2089",
                "rate-info_2091",
                "remind-tag_2090",
                "social-trigger_2096",
                "split-line_2092"
            ],
            "price_2085": [
                "wishlist_2093"
            ],
            "detail-info_2073": [
                "discount_2094",
                "split-line_2095",
                "sku_2097",
                "split-line_2098",
                "specifications_2099"
            ],
            "detail-freight_2078": [
                "freight_2100",
                "split-line_2101",
                "service_2102"
            ],
            "detail-other_2080": [
                "container_2103",
                "margin-line_2104",
                "container_2105",
                "overview_2106"
            ],
            "detail-footer_2081": [
                "social_2107",
                "recommend_2109",
                "platform-recommend_2108",
                "cross-link_2110"
            ],
            "container_2103": [
                "reviews_2111",
                "split-line_2112",
                "qa_2113"
            ],
            "container_2105": [
                "store-info_2114",
                "split-line_2115",
                "store-recommend_2116"
            ]
        }
    },
    "data": {
        "root": {
            "id": 2069,
            "type": "root",
            "faas": "root"
        },
        "i18n_2068": {
            "id": 2068,
            "type": "i18n",
            "faas": "i18n"
        },
        "meta_2070": {
            "id": 2070,
            "type": "meta",
            "faas": "meta"
        },
        "main-image_2071": {
            "id": 2071,
            "type": "main-image",
            "faas": "main-image"
        },
        "download-bar_2072": {
            "id": 2072,
            "type": "download-bar",
            "faas": "download-bar"
        },
        "detail-info_2073": {
            "id": 2073,
            "type": "detail-info",
            "faas": null
        },
        "detail-title_2074": {
            "id": 2074,
            "type": "detail-title",
            "faas": null
        },
        "margin-line_2075": {
            "id": 2075,
            "type": "margin-line",
            "faas": null
        },
        "elevator_2076": {
            "id": 2076,
            "type": "elevator",
            "faas": null
        },
        "banner_2077": {
            "id": 2077,
            "type": "banner",
            "faas": "banner"
        },
        "detail-freight_2078": {
            "id": 2078,
            "type": "detail-freight",
            "faas": null
        },
        "margin-line_2079": {
            "id": 2079,
            "type": "margin-line",
            "faas": null
        },
        "detail-other_2080": {
            "id": 2080,
            "type": "detail-other",
            "faas": null
        },
        "detail-footer_2081": {
            "id": 2081,
            "type": "detail-footer",
            "faas": null
        },
        "gdpr_2082": {
            "id": 2082,
            "type": "gdpr",
            "faas": null
        },
        "seller-invite_2083": {
            "id": 2083,
            "type": "seller-invite",
            "faas": "seller-invite"
        },
        "action-bar_2084": {
            "id": 2084,
            "type": "action-bar",
            "faas": "action-bar"
        },
        "price_2085": {
            "id": 2085,
            "type": "price",
            "faas": "price"
        },
        "vat_2086": {
            "id": 2086,
            "type": "vat",
            "faas": "vat"
        },
        "plus_2087": {
            "id": 2087,
            "type": "plus",
            "faas": "plus"
        },
        "biz-mind_2088": {
            "id": 2088,
            "type": "biz-mind",
            "faas": "biz-mind"
        },
        "title_2089": {
            "id": 2089,
            "type": "title",
            "faas": "title"
        },
        "remind-tag_2090": {
            "id": 2090,
            "type": "remind-tag",
            "faas": "remind-tag"
        },
        "rate-info_2091": {
            "id": 2091,
            "type": "rate-info",
            "faas": "rate-info"
        },
        "split-line_2092": {
            "id": 2092,
            "type": "split-line",
            "faas": null
        },
        "wishlist_2093": {
            "id": 2093,
            "type": "wishlist",
            "faas": "wishlist"
        },
        "discount_2094": {
            "id": 2094,
            "type": "discount",
            "faas": "discount"
        },
        "split-line_2095": {
            "id": 2095,
            "type": "split-line",
            "faas": null
        },
        "social-trigger_2096": {
            "id": 2096,
            "type": "social-trigger",
            "faas": null
        },
        "sku_2097": {
            "id": 2097,
            "type": "sku",
            "faas": "sku"
        },
        "split-line_2098": {
            "id": 2098,
            "type": "split-line",
            "faas": null
        },
        "specifications_2099": {
            "id": 2099,
            "type": "specifications",
            "faas": "specifications"
        },
        "freight_2100": {
            "id": 2100,
            "type": "freight",
            "faas": "freight"
        },
        "split-line_2101": {
            "id": 2101,
            "type": "split-line",
            "faas": null
        },
        "service_2102": {
            "id": 2102,
            "type": "service",
            "faas": "service"
        },
        "container_2103": {
            "id": 2103,
            "type": "container",
            "faas": null
        },
        "margin-line_2104": {
            "id": 2104,
            "type": "margin-line",
            "faas": null
        },
        "container_2105": {
            "id": 2105,
            "type": "container",
            "faas": null
        },
        "overview_2106": {
            "id": 2106,
            "type": "overview",
            "faas": "overview"
        },
        "social_2107": {
            "id": 2107,
            "type": "social",
            "faas": null
        },
        "platform-recommend_2108": {
            "id": 2108,
            "type": "platform-recommend",
            "faas": "platform-recommend"
        },
        "recommend_2109": {
            "id": 2109,
            "type": "recommend",
            "faas": null
        },
        "cross-link_2110": {
            "id": 2110,
            "type": "cross-link",
            "faas": "cross-link"
        },
        "reviews_2111": {
            "id": 2111,
            "type": "reviews",
            "faas": "reviews"
        },
        "split-line_2112": {
            "id": 2112,
            "type": "split-line",
            "faas": null
        },
        "qa_2113": {
            "id": 2113,
            "type": "qa",
            "faas": null
        },
        "store-info_2114": {
            "id": 2114,
            "type": "store-info",
            "faas": "store-info"
        },
        "split-line_2115": {
            "id": 2115,
            "type": "split-line",
            "faas": null
        },
        "store-recommend_2116": {
            "id": 2116,
            "type": "store-recommend",
            "faas": "store-recommend"
        }
    }
}

Share demo code

Would you consider sharing the demo code? I’m interested in a similar side-by-side display display. The current default display is co-nested line by line

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.