An open API service indexing awesome lists of open source software.

https://github.com/wagnercsfilho/react-redux-undo

A simple redux state undo
https://github.com/wagnercsfilho/react-redux-undo

react redux undo

Last synced: about 1 year ago
JSON representation

A simple redux state undo

Awesome Lists containing this project

README

          

### React Redux Undo

A simple reducer enhancer (or a higher order reducer) that allows you to undo/redo changes in the state.

#### Install

```
npm install react-redux-undo
```

With yarn

```
yarn add react-redux-undo
```

#### Who to use

```jsx
import { createStore } from "redux";
import { applyUndo, ActionCreators } from "react-redux-undo";

const store = createStore(applyUndo(reducer));

function App() {
return (



);
}

function Count() {
const counter = useSelector((state) => state.counter);
const dispatch = useDispatch();

return (


Counter {counter}


dispatch({ type: "ADD" })}>ADD COUNTER


dispatch(ActionCreators.undo())}>UNDO
dispatch(ActionCreators.clear())}>CLEAR
dispatch(ActionCreators.redo())}>UNDO

);
}
```

#### Passing custom props

Defines a maximum size of the history stack

```js
applyUndo(reducer, { maxHistory: 5 });
```

#### Example

[Check an example](https://codesandbox.io/s/funny-solomon-9tv78)

#### License

MIT