Como detectar se o aplicativo está perdendo o foco no react nativo
Copyimport { useFocusEffect } from '@react-navigation/native';
function Profile({ userId }) { const [user, setUser] = React.useState(null);
useFocusEffect( React.useCallback(() => { const unsubscribe = API.subscribe(userId, user => setUser(data));
return () => unsubscribe(); }, [userId]) );
return <ProfileContent user={user} />;}
Tame Teira