Socket
Socket
Sign inDemoInstall

react-diff-viewer

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-diff-viewer

A simple and beautiful text diff viewer component made with diff and React


Version published
Weekly downloads
131K
decreased by-1.27%
Maintainers
1
Weekly downloads
 
Created

What is react-diff-viewer?

react-diff-viewer is a React component library that provides a simple and customizable way to display differences between two pieces of text. It is commonly used for code review tools, version control systems, and any application that needs to show changes between two versions of text.

What are react-diff-viewer's main functionalities?

Basic Diff Viewer

This feature allows you to display a basic side-by-side diff view of two pieces of text. The `splitView` prop determines whether the diff is shown in a split view or inline.

import React from 'react';
import DiffViewer from 'react-diff-viewer';

const oldText = 'Hello World';
const newText = 'Hello React World';

const App = () => (
  <DiffViewer oldValue={oldText} newValue={newText} splitView={true} />
);

export default App;

Inline Diff Viewer

This feature allows you to display an inline diff view of two pieces of text. Setting the `splitView` prop to `false` will render the diff inline.

import React from 'react';
import DiffViewer from 'react-diff-viewer';

const oldText = 'Hello World';
const newText = 'Hello React World';

const App = () => (
  <DiffViewer oldValue={oldText} newValue={newText} splitView={false} />
);

export default App;

Customizing Diff Colors

This feature allows you to customize the colors used in the diff viewer. You can provide a `styles` prop with custom styles to change the background colors for added and removed lines, as well as word-level changes.

import React from 'react';
import DiffViewer from 'react-diff-viewer';

const oldText = 'Hello World';
const newText = 'Hello React World';

const customStyles = {
  variables: {
    light: {
      diffViewerBackground: '#f7f7f7',
      addedBackground: '#e6ffed',
      removedBackground: '#ffeef0',
      wordAddedBackground: '#acf2bd',
      wordRemovedBackground: '#fdb8c0',
    },
  },
};

const App = () => (
  <DiffViewer oldValue={oldText} newValue={newText} splitView={true} styles={customStyles} />
);

export default App;

Other packages similar to react-diff-viewer

Keywords

FAQs

Package last updated on 22 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc