HwangTaehyun / react-native-lottie-splash-screen

⚡ Lottie splash screen for your react native app!
MIT License
222 stars 62 forks source link

How to hide lottie splash screen when no internet? It continuously running if no network #53

Closed yuvrajchaudhari03 closed 1 year ago

yuvrajchaudhari03 commented 2 years ago

I have used LottieSplashScreen.hide() but when I switch off internet and open the app it continuously running

function Root() {
    const [isTryingLogin, setIsTryingLogin] = React.useState(true);

    const authCtx = React.useContext(AuthContext);

    React.useEffect(() => {
      if (isTryingLogin === false) {
        LottieSplashScreen.hide(); // here
      }
    }, [isTryingLogin]);
    React.useEffect(() => {
      async function fetchToken() {
        const storedToken = await AsyncStorage.getItem("token");

        if (storedToken) {
          authCtx.authenticate(storedToken);
        }

        setIsTryingLogin(false);

      }

      fetchToken();
    }, []);

    if (isTryingLogin) {
      return <Loader />;
    }

    return <Navigation />;
  }

@HwangTaehyun

HwangTaehyun commented 2 years ago

Ah.. I think that is not related to the network. It seems to be a problem with authCtx.authenticate though.

HwangTaehyun commented 1 year ago

I will close this issue!