Created
June 18, 2019 14:29
-
-
Save larchanka/4df26ae973d07f49d804165d519eb65f to your computer and use it in GitHub Desktop.
Function gets data from localstorage
This file contains 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
export default (itemName, defaultValue, postFn = (str) => str) => { | |
const item = localStorage.getItem(itemName); | |
if (item) { | |
return postFn(item); | |
} | |
return defaultValue; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment