Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
Uncaught TypeError: path.split is not a function in react

I am wondering how I can solve this with new ways of coding. I've seen someone say this error is due to the update of react-hook-form, but I am not sure how to solve this. If anyone knows this, I would appreciate it.

I originally tried to solve this by adding the "..." before register instead of using "ref=". I have also tried different placing of "name="email"" as answered in the similar question below; however, I am still getting this error.

Getting Uncaught TypeError: path.split is not a function in react

my error says: " Uncaught TypeError: path.split is not a function" and I am using "react-hook-form": "react-hook-form": "^7.33.1".

import React from 'react';
import { useForm } from 'react-hook-form';

const EMAIL_PATTERN = /^(([^<>()\\[\]\\.,;:\s@"]+(\.[^<>()\\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

const LoginForm = ({onSubmit}) => {

  const { register, handleSubmit, errors } = useForm();
  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <div className="form-group">
        <label htmlFor="email">Email</label>
        <input
          {...register({required: true, pattern: EMAIL_PATTERN})}
          name="email"
          type="email"
          className="form-control"
          id="email" />
        { errors.email &&
          <div className="alert alert-danger"> 
            { errors.email.type === 'required' &&
              <span>Email is required!</span>
            }
            { errors.email.type === 'pattern' &&
              <span>Not valid email format!</span>
            }
          </div>
        }
      </div>

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

As written in React Hook Form documentation (https://react-hook-form.com/api/useform/register) you should either supply input's name or id before the register options. Currently you're only providing the register options so it's giving you an error message as it tries to register with invalid name or id.

register: (name: string, RegisterOptions?) => ({ onChange, onBlur, name, ref })

In your case it should be the following.

  <input {...register("email", {required: true, pattern: EMAIL_PATTERN})}
          name="email"
          type="email"
          className="form-control"
          id="email" />

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda