All Projects → Tettra → React Visual Diff

Tettra / React Visual Diff

Licence: mit
React component for rendering the diff of two React elements

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Visual Diff

React Diff Viewer
A simple and beautiful text diff viewer component made with Diff and React.
Stars: ✭ 642 (+2818.18%)
Mutual labels:  diff
React Maskedinput
Masked <input/> React component
Stars: ✭ 700 (+3081.82%)
Mutual labels:  react-component
React Stack Grid
Pinterest like layout components for React.js
Stars: ✭ 803 (+3550%)
Mutual labels:  react-component
React S Alert
Alerts / Notifications for React with rich configuration options
Stars: ✭ 658 (+2890.91%)
Mutual labels:  react-component
React Awesome Query Builder
User-friendly query builder for React
Stars: ✭ 682 (+3000%)
Mutual labels:  react-component
Reactprimer
React component prototyping tool that generates fully connected class component code.
Stars: ✭ 743 (+3277.27%)
Mutual labels:  react-component
Sirix
SirixDB is a temporal, evolutionary database system, which uses an accumulate only approach. It keeps the full history of each resource. Every commit stores a space-efficient snapshot through structural sharing. It is log-structured and never overwrites data. SirixDB uses a novel page-level versioning approach called sliding snapshot.
Stars: ✭ 638 (+2800%)
Mutual labels:  diff
Sparkline
Lightweight React sparklines ✨ 📈
Stars: ✭ 19 (-13.64%)
Mutual labels:  react-component
Awesome React Components
Curated List of React Components & Libraries.
Stars: ✭ 28,626 (+130018.18%)
Mutual labels:  react-component
React Toastify
React notification made easy 🚀 !
Stars: ✭ 8,113 (+36777.27%)
Mutual labels:  react-component
Diffdom
A diff for DOM elements, as client-side JavaScript code. Gets all modifications, insertions and removals between two DOM fragments.
Stars: ✭ 660 (+2900%)
Mutual labels:  diff
React Input Range
React component for inputting numeric values within a range (range slider)
Stars: ✭ 680 (+2990.91%)
Mutual labels:  react-component
React Lazy Load Image Component
React Component to lazy load images and components using a HOC to track window scroll position.
Stars: ✭ 755 (+3331.82%)
Mutual labels:  react-component
React Extras
Useful components and utilities for working with React
Stars: ✭ 651 (+2859.09%)
Mutual labels:  react-component
Changeset
Minimal edits from one collection to another
Stars: ✭ 807 (+3568.18%)
Mutual labels:  diff
Xcdiff
A tool which helps you diff xcodeproj files.
Stars: ✭ 641 (+2813.64%)
Mutual labels:  diff
Java Object Diff
Library to diff and merge Java objects with ease
Stars: ✭ 725 (+3195.45%)
Mutual labels:  diff
Zfvimdirdiff
vim script to diff two directories like BeyondCompare by using `diff`
Stars: ✭ 22 (+0%)
Mutual labels:  diff
Base
React-UI-Kit - frontend library with ReactJS components
Stars: ✭ 18 (-18.18%)
Mutual labels:  react-component
React Insta Stories
A React component for Instagram like stories
Stars: ✭ 777 (+3431.82%)
Mutual labels:  react-component

react-visual-diff

A React Component that renders the structural differences of two React Elements

NPM JavaScript Style Guide

This module provides a way of visually rendering differences between React Elements. It was originally developed for tettra to visualize differences between two documents. It uses the deep-diff module under the hood.

Limitations:
  • All function props, such as onClick handlers are discarded when rendering a diff (However, you can make the diff interactive via the renderChange prop)
  • We're diffing the structure of two React Elements. react-visual-diff is not a visual regression tool.

Install

npm install --save react-visual-diff

Basic Usage

The most simple form of using the VisualDiff component is to just define two props - left and right:

import VisualDiff from 'react-visual-diff'

...

<VisualDiff
  left={<span>This is the left side</span>}
  right={<span>This is the left side</span>}
/>

Rendering changes

The default style for rendering changes is ok for basic needs, but usually you'll want to control this.

The renderChange prop lets you do this:

<VisualDiff
  left={<span>This is the left side</span>}
  right={<span>This is the right side</span>}
  renderChange={({ type, children }) => 
    type === 'added'
    ? <Added>{children}</Added>
    : <Removed>{children}</Removed>}
  />

Diffing only certain props

Basically, when two react elements are compared, they're first being serialized to objects and then diffed. By default the following props are diffed:

const diffProps = ['children', 'type', 'className', 'style']

If you'd like to restrict this to a different set, simply set the diffProps prop

For example:

<VisualDiff
  left={<span>This is the left side</span>}
  right={<span>This is the left side</span>}
  diffProps={['children']}
  />

This would only render differences of the children prop.

<VisualDiff> Props:

Property Type required? Description
left React.Element required Pass React.Element or just jsx left={<MyFancyComponent>}
right React.Element required Pass React.Element or just jsx right={<MyOtherFancyComponent>}
renderChange `Component<{ type: 'added' 'removed', children: React$Children }>` optional
diffProps Array<string> optional An array of prop names that will be diffed. defaults to ['children', 'type', 'className', 'style']

Roadmap

  • An example with draft js documents
  • Examples with various open source components
  • An example with interaction
  • Reduce file size (currently it's pretty big)
  • react-native support

License

MIT © Tettra

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].