Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@larchanka
Created June 18, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larchanka/4df26ae973d07f49d804165d519eb65f to your computer and use it in GitHub Desktop.
Save larchanka/4df26ae973d07f49d804165d519eb65f to your computer and use it in GitHub Desktop.
Function gets data from localstorage
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