Created
June 23, 2019 22:31
-
-
Save jsmanifest/75c4d085def7eaa8dcb6fef5a8d10d79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const insertToHistory = (state) => { | |
if (state && Array.isArray(state.history)) { | |
// Do not mutate | |
const newHistory = [...state.history] | |
newHistory.push(state) | |
return newHistory | |
} | |
console.warn( | |
'WARNING! The state was attempting capture but something went wrong. Please check if the state is controlled correctly.', | |
) | |
return state.history || [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment