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

Error while trying to use it with yup and yup resolver #152

Open
copy-ninja1 opened this issue Jan 26, 2025 · 0 comments
Open

Error while trying to use it with yup and yup resolver #152

copy-ninja1 opened this issue Jan 26, 2025 · 0 comments

Comments

@copy-ninja1
Copy link

/node_modules/remix-hook-form/dist/index.js:129
useSubmit
^^^^^^^^^
SyntaxError: Named export 'useSubmit' not found. The requested module 'react-router' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'react-router';

at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
at ModuleJob.run (node:internal/modules/esm/module_job:213:5)
at ModuleLoader.import (node:internal/modules/esm/loader:316:24)

Example

import * as yup from "yup";

export const SignUpSchema = yup.object().shape({
  firstName: yup.string().required("First Name is required"),
  lastName: yup.string().required("Last Name is required"),
  email: yup.string().email().required("Email Address is required"),
  phone: yup.string().required("Phone Number is required"),
  password: yup.string().required("Password is required"),
  confirmPassword: yup
    .string()
    .required("Confirm your Password")
    .oneOf([yup.ref("password")], "Passwords must match"),
  address1: yup.string().required("Address 1  is required"),
  address2: yup.string().optional(),
  gender: yup.string().required("gender is required"),
  timeZone: yup.string().optional(),
  city: yup.string().required("City is required"),
  state: yup.string().required("State is required"),
  postCode: yup.string().required("Post Code is required"),
});

export type SignUpSchema = yup.InferType<typeof SignUpSchema>;

  const {
    handleSubmit,
    formState: { errors },
    register,
  } = useRemixForm<SignUpSchema>({
    mode: "onSubmit",
    resolver: yupResolver(SignUpSchema),
  });
@copy-ninja1 copy-ninja1 changed the title Error while trying to to use it with yup and yup resolver Error while trying to use it with yup and yup resolver Jan 26, 2025
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

1 participant