visuddhinanda 3 лет назад
Родитель
Сommit
48d2b51341
1 измененных файлов с 13 добавлено и 12 удалено
  1. 13 12
      dashboard/src/components/auth/ToStudio.tsx

+ 13 - 12
dashboard/src/components/auth/ToStudio.tsx

@@ -1,22 +1,23 @@
 import { Button } from "antd";
 import { Button } from "antd";
-import { useEffect, useState } from "react";
+//import { useEffect, useState } from "react";
 import { Link } from "react-router-dom";
 import { Link } from "react-router-dom";
 import { useAppSelector } from "../../hooks";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 
 
 const Widget = () => {
 const Widget = () => {
-	const [userName, setUserName] = useState("");
 	const user = useAppSelector(_currentUser);
 	const user = useAppSelector(_currentUser);
-	useEffect(() => {
-		setUserName(user ? user.realName : "");
-	}, [user]);
-	return (
-		<>
-			<Link to={`/studio/${userName}/home`}>
-				<Button type="primary">藏经阁</Button>
-			</Link>
-		</>
-	);
+
+	if (typeof user !== "undefined") {
+		return (
+			<>
+				<Link to={`/studio/${user.realName}/home`}>
+					<Button type="primary">藏经阁</Button>
+				</Link>
+			</>
+		);
+	} else {
+		return <></>;
+	}
 };
 };
 
 
 export default Widget;
 export default Widget;