Created
November 17, 2018 05:17
-
-
Save leslie-alldridge/5c3a6866f00f5c7ad9e6fafad7a40f52 to your computer and use it in GitHub Desktop.
local storage
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 localStorage = global.window.localStorage; | |
export function get(key) { | |
return localStorage.getItem(key); | |
} | |
export function set(key, value) { | |
if (value === null) { | |
localStorage.removeItem(key); | |
} else { | |
localStorage.setItem(key, value); | |
} | |
} | |
export function remove(key) { | |
localStorage.removeItem(key); | |
} | |
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | |
handleUpVote = () => { | |
let votesUsed = get("voted"); | |
if (votesUsed >= 3) { | |
alert("No votes remaining"); | |
} else { | |
set("voted", Number(votesUsed) + 1); | |
this.props.onVote(this.props.id); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment