1.4.6 • Published 3 years ago

use-string-diff v1.4.6

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago

Build Status Version Downloads

Installation

This module is distributed via NPM which is bundled with NodeJS and should be installed as one of your project's dependencies:

npm install use-string-diff --save or yarn add use-string-diff

Usage

Single Value

import { useStringDiff } from 'use-string-diff'


const MyComponent = () => {
  const [state, setState] = useState('');

  const difference = useStringDiff(value);

  return (
    <div>
      <input
        onChange={(event) => {
                setState(event.target.value);
            }}
        value={value}
        />
    </div>
  )
}

Two Values

import { useStringDiff } from 'use-string-diff'

const INITIAL_STRING = 'Initial String';
const MyComponent = () => {

  const [state, setState] = useState(INITIAL_STRING);

  const difference = useStringDiff(INITIAL_STRING, state);

  return (
    <div>
      <input
        onChange={(event) => {
                setState(event.target.value);
            }}
      value={value}/>
    </div>
  )
}

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

LICENSE

MIT