I have the next problem:
export async function updateLessons() { 
  let data
  await database().goOnline().then(async () => {
    await database()
    .ref('days')
    .on('value', snapshot => {
      console.log(snapshot.val())
      data = snapshot.val();
    });
  });
  return data;
}
I use this function to update my application when I swipe down
  const onRefresh = React.useCallback(async () => {
    setRefreshing(true);
    setLessons(await updateLessons());
    console.log(lessons)
    setRefreshing(false);
  }, []);
It is called from scroll view (refreshcontrol)
The problem is that it doesn't work asynchronously. In console log i see my snapshot. But the application updated faster and in console.log(lessons) it is undefined. How can I fix it?
 
    