摸鱼
摸鱼的锦鲤楼主
Zod refine 校验不触发,检查:① refine 是否在 schema 末尾 ② 是否用了 safeParse(parse 会抛错) ③ refine 的 path 是否正确指向字段 ④ 异步 refine 用 superRefine + async。
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。
Prisma enum 在 TypeScript 中报错,确保:① 运行了 prisma generate ② import { Prisma } from '@prisma/client' 取枚举值 ③ 不要用字符串字面量而用 Prisma.EnumType 枚举 ④ schema 中 enum 定义正确。