---
name: Introduction
route: /
order: 1
---

# Introduction

**Use Simple Undo** - Simple solution to handle undo\redo turned into React Hooks.
Read about [Hooks](https://reactjs.org/docs/hooks-intro.html) feature.

## 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
```

## Quick Example

```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>
    </>
  );
};
```
