I am trying to use React Hook Form package in my form for validation and got this error when I refreshed the page. The idea is to collect the form input, validate it before sending to the server. However, I cannot get beyond this error message and don't know where to begin fixing it. Can Do you know how to fix it, if so - please help point me in the right direction on how to fix it?
My Form field
import React, { useEffect } from 'react';
import { useForm } from 'react-hook-form';
const login = () => {
const {register, handleSubmit} = useForm();
return (
<div>
<div className="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8 bg-gradient-to-r from-gray-700 via-gray-800 to-gray-900">
<div className="sm:mx-auto sm:w-full sm:max-w-md">
<h2 className="mt-6 text-center text-3xl font-extrabold text-white">
Sign in to your account
</h2>
<p className="mt-2 text-center text-sm text-gray-600 max-w">
Or
<a href="/register" className="font-medium text-indigo-600 hover:text-indigo-500">
Register for an account
</a>
</p>
</div>
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div className="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
{/* Form */}
<form className="space-y-6" action="/login" method="POST" onSubmit={handleSubmit((data)=>{
alert(JSON.stringify(data))
})}>
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email address
</label>
<div className="mt-1">
<input ref={register} id="email" name="email" type="email" autoComplete="email" required className="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" />
</div>
</div>
<div>
<label htmlFor="password" className="block text-sm font-medium text-gray-700">
Password
</label>
<div className="mt-1">
<input ref={register} id="password" name="password" type="password" autoComplete="current-password" required className="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" />
</div>
</div>
<div className="flex items-center justify-between">
<div className="flex items-center">
<input ref={register} id="remember_me" name="remember_me" type="checkbox" className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" />
<label htmlFor="remember_me" className="ml-2 block text-sm text-gray-900">
Remember me
</label>
</div>
<div className="text-sm">
<a href="#" className="font-medium text-indigo-600 hover:text-indigo-500">
Forgot your password?
</a>
</div>
</div>
<div>
<button type="submit" className="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Sign in
</button>
</div>
</form>
<div className="mt-6">
<div className="relative">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-gray-300" />
</div>
<div className="relative flex justify-center text-sm">
<span className="px-2 bg-white text-gray-500">
Or continue with
</span>
</div>
</div>
<div className="mt-6 grid grid-cols-2 gap-3">
<div>
<a href="#" className="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
<span className="sr-only">Sign in with Google</span>
<img className="g-tile" src="/google-tile.png" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
Error
Unhandled Runtime Error TypeError: path.split is not a function
Call Stack
get node_modules/react-hook-form/dist/index.esm.js (28:0) eval node_modules/react-hook-form/dist/index.esm.js (1426:0) commitAttachRef node_modules/react-dom/cjs/react-dom.development.js (20023:0) commitLayoutEffects node_modules/react-dom/cjs/react-dom.development.js (22808:0) HTMLUnknownElement.callCallback node_modules/react-dom/cjs/react-dom.development.js (188:0) Object.invokeGuardedCallbackDev node_modules/react-dom/cjs/react-dom.development.js (237:0) invokeGuardedCallback node_modules/react-dom/cjs/react-dom.development.js (292:0) commitRootImpl node_modules/react-dom/cjs/react-dom.development.js (22541:0) unstable_runWithPriority node_modules/scheduler/cjs/scheduler.development.js (653:0) runWithPriority$1 node_modules/react-dom/cjs/react-dom.development.js (11039:0) commitRoot node_modules/react-dom/cjs/react-dom.development.js (22381:0) finishSyncRender node_modules/react-dom/cjs/react-dom.development.js (21807:0) performSyncWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js (21793:0) scheduleUpdateOnFiber node_modules/react-dom/cjs/react-dom.development.js (21188:0) updateContainer node_modules/react-dom/cjs/react-dom.development.js (24373:0) eval node_modules/react-dom/cjs/react-dom.development.js (24758:0) unbatchedUpdates node_modules/react-dom/cjs/react-dom.development.js (21903:0) legacyRenderSubtreeIntoContainer node_modules/react-dom/cjs/react-dom.development.js (24757:0) Object.hydrate node_modules/react-dom/cjs/react-dom.development.js (24823:0) renderReactElement node_modules/next/dist/client/index.js (530:6) doRender node_modules/next/dist/client/index.js (799:2) _callee2$ node_modules/next/dist/client/index.js (425:10) tryCatch node_modules/regenerator-runtime/runtime.js (63:14) Generator.invoke [as _invoke] node_modules/regenerator-runtime/runtime.js (293:0) Generator.eval [as next] node_modules/regenerator-runtime/runtime.js (118:0) asyncGeneratorStep node_modules/@babel/runtime/helpers/asyncToGenerator.js (3:0) _next node_modules/@babel/runtime/helpers/asyncToGenerator.js (25:0) eval node_modules/@babel/runtime/helpers/asyncToGenerator.js (32:0) new Promise <anonymous> eval node_modules/@babel/runtime/helpers/asyncToGenerator.js (21:0) _render webpack-internal:///./node_modules/next/dist/client/index.js (522:18) render webpack-internal:///./node_modules/next/dist/client/index.js (459:18) eval node_modules/next/dist/client/next-dev.js (85:6) eval node_modules/next/dist/client/dev/fouc.js (14:6)