Skip to content

Commit af25d79

Browse files
committed
修复一些警告
1 parent 2300bc6 commit af25d79

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/use-auth.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
7878
// 2. 读取存储的 token,调用后端验证并获取用户信息
7979
const token = urlToken ?? getStoredToken();
8080
if (!token) {
81-
setStatus("unauthenticated");
81+
// 异步设置,避免在 effect 中同步调用 setState 触发级联渲染
82+
Promise.resolve().then(() => setStatus("unauthenticated"));
8283
return;
8384
}
8485

0 commit comments

Comments
 (0)