小编Ari*_*aul的帖子

How to prevent UI flickering while conditionally rendering components?

Consider the following code:

const Home = () => {
  const [user, setUser] = useState(null);

  useEffect(() => {
    const unsubscribe = auth.onAuthStateChanged(authUser => {
      if(authUser) {
        setUser(authUser);
      } else {
        setUser(null)
      }
    });

    return () => unsubscribe();
  }, []);

  return (
    <div>
      {user ? (
        <Hero />
      ) : (
        <Login />
      )}
    </div>
  )
}

export default Home
Run Code Online (Sandbox Code Playgroud)

The Login component has all the functions which handles all the Sign Up, Login and Third-Party Authentications using Firebase.

The problems …

firebase reactjs firebase-authentication

7
推荐指数
1
解决办法
8315
查看次数