Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: useffect didnt trigger for the last one #615

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions expo/src/components/CustomBootsplash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from "react";
import React, { useEffect, useRef, useState } from "react";
import { Image, Dimensions, Animated, StyleSheet } from "react-native";
import { atom, useRecoilValue } from "recoil";

Expand All @@ -11,16 +11,21 @@ export const showBootSplashState = atom({
const CustomBootsplash = () => {
const showBootSplash = useRecoilValue(showBootSplashState);
const fadeAnim = useRef(new Animated.Value(0)).current;
const [animationComplete, setAnimationComplete] = useState(false);

useEffect(() => {
Animated.timing(fadeAnim, {
toValue: showBootSplash ? 1 : 0,
duration: 200,
useNativeDriver: true,
}).start();
}, [fadeAnim, showBootSplash]);
}).start(({ finished }) => {
if (finished) {
setAnimationComplete(!showBootSplash);
}
});
}, [showBootSplash]);

if (!showBootSplash && fadeAnim._value === 0) return null;
if (!showBootSplash && animationComplete) return null;

return (
<Animated.View style={[styles.fullScreen, { opacity: fadeAnim }]}>
Expand Down
Loading