use-string-diff
Advanced tools
Comparing version 1.4.5 to 1.4.6
{ | ||
"name": "use-string-diff", | ||
"version": "1.4.5", | ||
"version": "1.4.6", | ||
"description": "custom react hook to get the difference between two strings", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
@@ -11,4 +11,74 @@ <div align="center"> | ||
 | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Issues](#issues) | ||
- [🐛 Bugs](#-bugs) | ||
- [💡 Feature requests](#-feature-requests) | ||
- [LICENSE](#license) | ||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
## 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 |
5388
84