Skip to content

brense/react-immer-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-immer-hook

Provides a hook for immerjs that supports patches

Getting started

Installation

npm i immer react-immer-hook

Usage

import useImmer from 'react-immer-hook'

function App() {
  const [value, produceValue, { undo, redo }] = useImmer('')
  return <>
    <input value={value} onChange={(e) => produceValue(() => e.target.value)} />
    <Button onClick={() => undo()}>Undo</Button>
    <Button onClick={() => redo()}>Redo</Button>
  </>
}

export default App

About

Hook for immerjs that supports patches

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published