diff --git a/src/hooks/utils/history.js b/src/hooks/utils/history.js index 5841906..9153655 100644 --- a/src/hooks/utils/history.js +++ b/src/hooks/utils/history.js @@ -21,11 +21,18 @@ export function useHistory(initialState) { if (state === history[0]) return; - const newHistory = [ + let newHistory = [ state, ...history.slice(stateIndex, history.length) ]; + // Remove repeated states + newHistory = newHistory.filter((state, index) => { + return state !== newHistory[index + 1]; + }); + + console.log(newHistory); + setHistory(newHistory); setStateIndex(0); };