Created
April 21, 2018 17:47
-
-
Save ryanjyost/6c5129dde0bee7bf4f4cc27912fbe720 to your computer and use it in GitHub Desktop.
saveStateToLocalStorage()
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
| saveStateToLocalStorage() { | |
| // for every item in React state | |
| for (let key in this.state) { | |
| // save to localStorage | |
| localStorage.setItem(key, JSON.stringify(this.state[key])); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment