You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there are any plans to provide an option to use useLayoutEffect instead of useLayout?
If on application load useAuthState is leveraged to determine whether to render a sign in screen or user dashboard, then the sign in screen is painted before the component receives the updated state. That causes a quick flash of the sign in screen.
This causes PublicRoutes to flash:
constRoutes=()=>{const{ user }=useAuthState()return(user
? <AuthenticatedRoutes/>// <-- user dashboard is here
: <PublicRoutes/>// <-- sign in screen is here)}
I think it stopped because I combined a couple components. Before I had Routes and my App component separate, that resulted in multiple useAuthState calls.
@joserocha3 This is the reason why useAuthState returns a loading flag, as there may be a slight delay whilst Firebase validates the authentication token that it persisted in a previous session.
Generally, you need to account for 3 states rather than 2:
Are there are any plans to provide an option to use
useLayoutEffect
instead ofuseLayout
?If on application load
useAuthState
is leveraged to determine whether to render a sign in screen or user dashboard, then the sign in screen is painted before the component receives the updated state. That causes a quick flash of the sign in screen.This causes
PublicRoutes
to flash:Here is a proposed change to
useAuthState.ts
:The text was updated successfully, but these errors were encountered: