-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
currently the way some things are done in the app is not following best practices when using react
for example these two useEffects in src/screens/wallet/WalletScreen.js :
useEffect(() => {
if (userAccount !== null && typeof userAccount.isWinner === 'boolean') {
setShowAnnouncementModal(true);
}
}, [userAccount]);
so basically if we want to clean up this useEffect we can do it this :
useEffect(() => {
let mounted =true
if (userAccount !== null && typeof userAccount.isWinner === 'boolean' && mounted ) {
setShowAnnouncementModal(true);
}
//useEffects returns this function when its Parent component is unmounted in this case its WalletScreen
return ()=>{
mounted=false
}
}, [userAccount]);
what this does is that it'll try to setShowAnnouncementModal only if the WalletScreen component is till mounted
they should be writing this way
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels