Reputation: 419
I want to run my animations from react-native-reanimated everytime my screen is focused. How can I achieve this.
Upvotes: 0
Views: 910
Reputation: 23
I am not sure whether I understand your question correctly, but in most cases you can use the useIsFocused hook from react navigation.
like this:
import React from "react";
import { useIsFocused } from '@react-navigation/native';
function YourScreenScreen() {
const isFocused = useIsFocused();
React.useEffect(() => {
//put whatever you want here when the screen is focused
}, [isFocused]);
return <>......</>;
}
more reference here Hope this answers your question, Gl!
Upvotes: 1