Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sandiiarov/use-simple-undo
🔄 Simple solution to handle undo\redo turned into React Hooks
https://github.com/sandiiarov/use-simple-undo
Last synced: 4 months ago
JSON representation
🔄 Simple solution to handle undo\redo turned into React Hooks
- Host: GitHub
- URL: https://github.com/sandiiarov/use-simple-undo
- Owner: sandiiarov
- Created: 2018-11-08T19:00:08.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-17T11:36:55.000Z (5 months ago)
- Last Synced: 2024-09-17T14:16:22.034Z (5 months ago)
- Language: TypeScript
- Homepage: https://sandiiarov.github.io/use-simple-undo
- Size: 3.98 MB
- Stars: 30
- Watchers: 2
- Forks: 1
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- fucking-awesome-react-hooks - `use-simple-undo`
- awesome-react-hooks-cn - `use-simple-undo`
- awesome-react-hooks - `use-simple-undo`
- awesome-react-hooks - `use-simple-undo`
README


**Use Simple Undo** - Simple solution to handle undo\redo turned into React Hooks.
Read about [Hooks](https://reactjs.org/docs/hooks-intro.html) feature.## Documentation
https://sandiiarov.github.io/use-simple-undo
## Installation
> Note: React 16.8+ is required for Hooks.
### With npm
```sh
npm i use-simple-undo
```### Or with yarn
```sh
yarn add use-simple-undo
```## Usage
```jsx
import useSimpleUndo from 'use-simple-undo';
``````jsx
const Counter = () => {
const [state, cursor, setValue, { undo, redo }] = useSimpleUndo(0);const value = state[cursor];
const increment = () => setValue(value + 1);
const decrement = () => setValue(value - 1);return (
<>
{value}
increment
decrement
undo
redo
>
);
};
```