小编Arc*_*Use的帖子

如何在 React 中的条件语句后使用钩子?

我使用React firebase hooks 库有以下代码:

\n
    // load user state \n    const [user, loadingAuthState, errorAuthState] = useAuthState(auth);\n\n    // user is loading...\n    if(loadingAuthState)\n    {\n      return <div>\xd7\x98\xd7\x95\xd7\xa2\xd7\x9f...</div>\n    }\n    // an error has occured\n    else if(errorAuthState)\n    {\n      alert(errorAuthState);\n      return <Redirect to="login"/>\n    }\n    // if the user is not set, return to the login page\n    else if(!(user))\n    {\n      return (<Redirect to="/login"/>)\n    }\n\n    // load data from the user using the user\'s ID.\n    const [value, loading, error] = useDocumentData(doc(db, "users", user.uid));\n
Run Code Online (Sandbox Code Playgroud)\n

我收到此错误:

\n
\n …

reactjs firebase-authentication

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

标签 统计

firebase-authentication ×1

reactjs ×1