How can I solve TypeError: path.split is not a function

Viewed 5906

Now I'm using react-hook-form for login validation.

But, TypeError: path.split is not a function errors continue to occur when ref={register} is entered in input tag.

import React from 'react';
import {useForm} from "react-hook-form";
import './Auth.css';

export default function Register() {

    const {register, errors, watch} = useForm();

    return (
        <div>
            <form>
                <label>Email</label>
                <input type="email" name="email" ref={register({ required: true})} />
                <label>Password</label>
                <input type="password" />
                <label>Password Confirm</label>
                <input type="password"/>
                <input type="submit" />
            </form>
        </div>
    );
}

Even I copied and pasted the example code, the same error occurs, so how can I solve it?

The error code is as follows. enter image description here

2 Answers

Try this:

<input placeholder="To" type="email" {...register('email', { required: true })} />
Related