What would be the best way to await the check of s...
# help
v
What would be the best way to await the check of setUser(session.user) or setUser(null), right now my application has a flicker because the setLoading(false) happens before that check is complete.
Copy code
const { user, setUser } = useContext(AuthenticatedUserContext);
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    const { data: listener } = supabase.auth.onAuthStateChange(async (_, session) => {
      session?.user ? setUser(session.user) : setUser(null);
    });

    setIsLoading(false);
    return () => {
      listener?.unsubscribe();
    };
  }, []);
n
Hello @Vik! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.