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
/* | |
reuse a promise for multiple resolve()s since promises only resolve once and then never again | |
*/ | |
import React, { useEffect, useState } from 'react' | |
export default () => { | |
const [somePromise, setSomePromise] = useState(promiseCreator()) | |
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
/* | |
storeData(key=<STRING>, value=<STRING/OBJECT>) | |
getData(key=<STRING>) will return promise with either string or object type - whichever was stored. | |
example store & retrieve STRING: | |
storeData('key', "this is a string").then(() => { | |
getData('key').then(data => { | |
console.log(data) // => this is a atring | |
}) |