回滚
回滚艺术家楼主
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。 遇到 hydration mismatch 报错,一般是服务端和客户端渲染的 HTML 不一致。常见原因:① 在组件中用了 Date.now() 或 Math.random() ② 用了 window/document 等浏览器 API ③ 服务端和客户端时区不同。解决:把动态值放到 useEffect 里设置,或加 suppressHydrationWarning。 router.push 不更新 URL,Next.js 15 + next-intl 在 useSession 触发 re-render 时可能取消 router.push 的 startTransition。解决:用 window.location.href 硬导航(认证流程的例外允许裸路径)。 Google OAuth 回调报 OAuthCallback 错误,检查:① GOOGLE_CLIENT_ID/SECRET 是否正确 ② NEXTAUTH_URL 是否与 Google Console 中的回调 URL 一致 ③ redirect URI 是否匹配 ④ 时钟同步问题。