Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
Estoy usando React Hook Form con Typescript, la cadena no acepta datos entrantes

Cuando envío {...register(name)} a mi componente de entrada con el formulario de enlace, aparece un error, pero cuando lo envío como {...register("fullname")} no recibe ningún error. No puedo usar algo como ("fullname") porque lo estoy enviando usando la función de mapa.

registro.tsx

 import { Form, Input, PrimaryButton } from "components"; import { LoginRegisterLayout } from "layouts"; import { formTypes } from "constants/layouts/loginRegisterLayout"; import { getFormFields } from "constants/pages/register"; import { FormFieldType } from "utils/formFieldType"; import { useForm, SubmitHandler } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; type Inputs = { fullname: string; email: string; password: string; passwordConfirmation: string; }; const Register = () => { const { register, handleSubmit, watch, formState: { errors }, } = useForm<Inputs>(); const onSubmit: SubmitHandler<Inputs> = data => console.log(data); return ( <LoginRegisterLayout formType={formTypes.REGISTER} headTitle="Register"> <form onSubmit={handleSubmit(onSubmit)}> <> {getFormFields.map( ( { id, name, label, placeholder, type, passwordField, }: FormFieldType, index: number ) => ( <Input {...register(name)} label={label} id={id} name={name} key={index} placeholder={placeholder} type={type} passwordField={passwordField} /> ) )} <PrimaryButton size="xl" disabled={false}> Confirmation </PrimaryButton> </> </form> </LoginRegisterLayout> ); }; export default Register;

He adjuntado el error que obtuve como una imagen a continuación.

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intenta definir un tipo como este

 {getFormFields.map( ( { id, name, label, placeholder, type, passwordField, }: FormFieldType, index: number ) =>{ const nam : Inputs = name return( <Input {...register(nam)} label={label} id={id} name={name} key={index} placeholder={placeholder} type={type} passwordField={passwordField} /> ) } )}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!