'React native firebase getting a snapshot first time

The problem is. In React-Native-Firebase I try to get a snapshot from firebase.But when there is no internet and the program is started firstly (no locally saved snapshot) it is just freezed on .then(snapshot => { so I can't even get it in my try catch to show some notification to the use.How to fix it?

useEffect(() => {
async function prepare() {
  try {
    database().setPersistenceEnabled(true);
    await SplashScreen.preventAutoHideAsync();
    await Font.loadAsync(AntDesign.font);
    await database().goOffline()
    await database()
    .ref('days')
    .once('value')
    .then(snapshot => {
      if (snapshot.exists) {
        setLessons(snapshot.val());
      }
      else {
        throw new Error('Failed to fetch ideas');
      }
    })
  } catch (Error) {
    await SplashScreen.hideAsync();
    return(
      <View style={{flex: 1, paddingTop: 30}}>
        <StatusBar style='auto'/>
        <Text>Check your connection</Text>
      </View>
    )
  } finally {
    setAppIsReady(true);
  }
} 

prepare();
 }, []);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source