Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable: z #3966

Open
guyrandalf opened this issue Feb 3, 2025 · 1 comment
Open

ReferenceError: Can't find variable: z #3966

guyrandalf opened this issue Feb 3, 2025 · 1 comment

Comments

@guyrandalf
Copy link

Working with react19 on nextjs 15

Image

But I get the following error sometimes before or after I submit the form

Image

`import * as z from "zod";

export const signupSchema = z.object({
firstName: z.string().min(2, "First name must be at least 2 characters"),
lastName: z.string().min(2, "Last name must be at least 2 characters"),
email: z.string().email("Invalid email address"),
password: z.string().min(6, "Password must be at least 6 characters"),
});

export type SignupValues = z.infer;
`

@saez-juan
Copy link

Hi!
You need to import zod this way:

import { z } from "zod";

export const signupSchema = z.object({
  firstName: z.string().min(2, "First name must be at least 2 characters"),
  lastName: z.string().min(2, "Last name must be at least 2 characters"),
  email: z.string().email("Invalid email address"),
  password: z.string().min(6, "Password must be at least 6 characters"),
});

export type SignupValues = z.infer<typeof signupSchema>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants