yarn add @fa-repo/undo-redo --dev
import UndoRedo from '@fa-repo/undo-redo';
import arrayMove from 'array-move';
let items = ['apple', 'pear', 'mango'];
const undoRedo = new UndoRedo();
const moveItem = (from, to) => {
undoRedo.add({
do: () => arrayMove(items, from, to),
undo:() => arrayMove(items, to, from),
})
}
const undoChanges = () => {
undoRedo.undo();
}
const redoChanges = () => {
undoRedo.redo();
}
MIT