Wrap Screen components into FadeView compoent
and don't forget to add unmountOnBlur: true in the screenOptions
fade-view.tsx
import { cn } from "@/lib/utils";
import { View } from "react-native";
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
type FadeViewProps = {
children: React.ReactNode;
className?: string;
};
export default function FadeView({ children, className }: FadeViewProps) {
return (
<View className={cn("flex-1 bg-white")}>
<Animated.View
className={cn("flex-1", className)}
entering={FadeIn}
exiting={FadeOut}
>
{children}
</Animated.View>
</View>
);
}
index.tsx
...
import FadeView from "@/components/animation/fade-view";
export default function Index() {
return (
<FadeView>
...
</FadeView>
);
}
I just wrapped every component except _layout inside (tabs) into