Undo and Redo functionality for jeux apps
npm install jeux-undoAdds undo and redo to Jeux applications
``bash`
npm install jeux-undo
`javascript
import {undoRedo} from "jeux-undo"
// counter reducer
function counter (state = 0, action){
if(action.type ==="INC"){
return state + 1
}
if(action.type === "DEC"){
return state - 1;
}
return state;
}
export undoCounter = undoRedo(counter);
// seperate file
// instance of jeux store
// mock state
const state = {
counter: 0
}
store.dispatch({type : "INC"})
// state.counter has a value of 1
store.dispatch({type : "UNDO"})
// state.counter has a value of 0
``
Please make sure to update tests as appropriate.