Skip to content

Instantly share code, notes, and snippets.

@JacobThaDev
Created March 16, 2024 15:03
Show Gist options
  • Save JacobThaDev/d25698073e7f488d2289847a335977ad to your computer and use it in GitHub Desktop.
Save JacobThaDev/d25698073e7f488d2289847a335977ad to your computer and use it in GitHub Desktop.
How to update the state from previous case study
const update = () => {
// can not be within 5 seconds of each other.
if (account.getLastUpdate() - new Date().getTime() < 5000) {
return;
}
// update account then reset the state so it updates!
account.update().then((returnedScope: any) => {
let currentTime = new Date().getTime();
setAccount(returnedScope); // update account data!
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment