We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2300bc6 commit af25d79Copy full SHA for af25d79
1 file changed
lib/use-auth.tsx
@@ -78,7 +78,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
78
// 2. 读取存储的 token,调用后端验证并获取用户信息
79
const token = urlToken ?? getStoredToken();
80
if (!token) {
81
- setStatus("unauthenticated");
+ // 异步设置,避免在 effect 中同步调用 setState 触发级联渲染
82
+ Promise.resolve().then(() => setStatus("unauthenticated"));
83
return;
84
}
85
0 commit comments