Last active
March 29, 2021 12:24
-
-
Save thenriquedb/de858729a33885db9c4ae0850ab3c016 to your computer and use it in GitHub Desktop.
Garante o unmount e mount do componente
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
useEffect(() => { | |
let isUnmonted = false; | |
const runAsync = async () => { | |
try { | |
if (!isUnmonted) { } // Performa o update | |
} catch (e) { | |
if (!isUnmonted) { } // Gerencia o erro | |
} | |
}; | |
runAsync(); | |
return () => { | |
isUnmonted = true; // atualizar a variavel | |
}; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment