# use-simple-undo

Latest version **1.0.4** (published 2019-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-simple-undo
pnpm add use-simple-undo
yarn add use-simple-undo
bun add use-simple-undo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-02-14 |
| First published | 2018-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 480.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | alexsandiyarov |

## Links

- npm: https://www.npmjs.com/package/use-simple-undo
- npm.io page: https://npm.io/package/use-simple-undo

## Recent versions

- 1.0.4 (latest) — 2019-02-14
- 1.0.3 — 2019-02-09
- 1.0.2 — 2019-02-09
- 1.0.1 — 2019-02-09
- 1.0.0 — 2018-11-09
- 0.0.0 — 2018-11-08

## README

<h1 align="center">
  <img src="https://svgshare.com/i/9Ff.svg" alt="Use Events" />
</h1>

![npm](https://img.shields.io/npm/dt/use-simple-undo.svg)
![npm](https://img.shields.io/npm/v/use-simple-undo.svg)
![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/use-simple-undo.svg)
![NpmLicense](https://img.shields.io/npm/l/use-simple-undo.svg)

**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

# Install

> 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 (
    <>
      <div>{value}</div>
      <button onClick={increment}>increment</button>
      <button onClick={decrement}>decrement</button>
      <button onClick={undo}>undo</button>
      <button onClick={redo}>redo</button>
    </>
  );
};
```

---
_Source: https://npm.io/package/use-simple-undo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
