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

154
Visualizações
How to solve "cannot read properties of type undefined" when trying to send form input data to the backend?

I am trying to send a username that the user fills out to my server. I already have a post request that sends other information to the server and I would like to use the same post request and just add the new username value into the list of things that im sending. I keep getting this error even though I have given my form input a type="text"

here is my code for the form:

import React, { useState } from "react";

export default function UserForm() {
  const [values, setValues] = useState();

  const onSubmit = async (event) => {
    event.preventDefault();
  };

  function setUserValues() {
    setValues(values.user);
  }

  useState(setUserValues);
  if (values.user === undefined) {
    return;
  }

  return (
    <form onSubmit={onSubmit}>
      <label>User*:</label>
      <input
        type="text"
        value={values.user}
        id="user"
        name="user"
        onChange={setImmediate("user")}
      />
      <button type="submit">Submit</button>
    </form>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try something like this

import React, { useState } from "react";

export default function UserForm() {
  const [values, setValues] = useState();
  
  const edit = (e) => {
    setValues(e.target.value)
  }

  return (
    <form onSubmit={onSubmit}>
      <label>User*:</label>
      <input
        type="text"
        value={values}
        id="user"
        name="user"
        onChange={edit()}
      />
      <button type="submit">Submit</button>
    </form>
  );
}
about 4 years ago · Juan Pablo Isaza 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