Created
December 30, 2022 22:53
-
-
Save kivircik-parantez/df5f82771c8bdfc40db820620752a399 to your computer and use it in GitHub Desktop.
Only runs once per app load
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
let didInit = false; | |
function App() { | |
useEffect(() => { | |
if (!didInit) { | |
didInit = true; | |
// ✅ Only runs once per app load | |
loadDataFromLocalStorage(); | |
checkAuthToken(); | |
} | |
}, []); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment