-
I've updated my next.js project from RHF 6.15.5 to 7.0.3 and switched from @hookform/resolvers:1.3.0 to 2.0.0. I'm using I also ran the update script:
Now, when the form is submitted, I get the following error: Unhandled Runtime Error
TypeError: (0 , react_hook_form__WEBPACK_IMPORTED_MODULE_0__.set) is not a function
Call Stack
a node_modules/@hookform/resolvers/dist/resolvers.module.js (1:106)
eval node_modules/@hookform/resolvers/yup/dist/yup.module.js (1:645)
async eval node_modules/react-hook-form/dist/index.esm.js (1213:40)
import React from 'react'
import { useForm } from 'react-hook-form'
import { yupResolver } from '@hookform/resolvers/yup'
import * as yup from 'yup'
import log from 'loglevel'
import { t } from 'i18n'
export default function SearchForm({ className = '', onResults, onError, onFocus }) {
const validationSchema = yup.object().shape({
searchTerm: yup.string().required()
})
const { register, handleSubmit } = useForm({
mode: "onSubmit",
resolver: yupResolver(validationSchema)
})
const onSubmit = (data) => {
log.debug('onSubmit', data);
}
return (
<form id='siteSearchForm' className={className} onSubmit={handleSubmit(onSubmit)}>
<label htmlFor="searchTerm" className="sr-only">
{t('search.term')}
</label>
<input
type="text"
{...register('searchTerm', {required: true})}
placeholder={t('search.placeholder')}
onFocus={() => { if (onFocus) { onFocus() }}} />
<div >
<button type="submit">
{t('search.title')}
</button>
</div>
</form>
);
} Anything obviously wrong with what I'm doing here? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 13 replies
-
Hi @stephent Have you tried to remove your The code looks good, can you share a codesandbox or repository with your problem please ? |
Beta Was this translation helpful? Give feedback.
-
Same issue. Removing |
Beta Was this translation helpful? Give feedback.
-
I used an old version of react hook form: "react-hook-form": "^6.15.5" with "@hookform/resolvers": "^2.6.1". I updated and the error is gone. |
Beta Was this translation helpful? Give feedback.
-
Having the same issue after updating react to 18 |
Beta Was this translation helpful? Give feedback.
-
I'm having this same issue "Error: (0 , react_hook_form__WEBPACK_IMPORTED_MODULE_6__.useForm) is not a function" Callstack:
Packages installed: My Code:
I've tried deleting my node_modules and reinstalling all dependencies, but nothing changes. |
Beta Was this translation helpful? Give feedback.
-
For those using Next.js in the App directory, ensure that you place |
Beta Was this translation helpful? Give feedback.
-
For me, I write 'use client' in top file and resolver for me |
Beta Was this translation helpful? Give feedback.
-
if you are using Next js I think the solution is just to input "use client" at the top of your code 😒😒 l had this error but "use client" was the solution |
Beta Was this translation helpful? Give feedback.
-
I am working on NextJS project and after setting the page as |
Beta Was this translation helpful? Give feedback.
-
import { zodResolver } from "@hookform/resolvers"; const studentValidationSchema = z.object({ const { ERROR------------------------- Source 41 | formState: { errors },
I re-install node modules as well update the @hookform/resolvers. It is not working for me :(( |
Beta Was this translation helpful? Give feedback.
Hi @stephent
Have you tried to remove your
node_modules
and re-install your project ? It seems you're using RHF 6 (theset
function is not exported in the v6 while version 7 exports it)The code looks good, can you share a codesandbox or repository with your problem please ?