Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
How to submit empty value and make it send None as a string react

I am trying to send an empty value and when I submit it, it send "None" to the data.

Here is my code base:

  const [addLoanClause, setAddLoanClause] = useState("");

  const handleSubmit = () => {

if (id) {
  var loanProposalDetailsUpdateObject = {
    ...
    addLoanClause: addLoanClause,
  };
  if (dataChanged(loanProposalDetailsUpdateObject)) {
    updateUserLoanProposalRequest({
      loanProposalDetails: loanProposalDetailsUpdateObject,
    }).then(() => {
      routeToNextPage(isUserLoanRequestInitiator, router, id);
    });
  }
  else {
    routeToNextPage(isUserLoanRequestInitiator, router, id);
  }
} else {
  props
    .createUserLoanRequest({
      requestType: transactionType,
      status: "draft",
      loanProposalDetails: {
        ...
        addLoanClause: addLoanClause,
      },
    })
    .then(data => {
      routeToNextPage(isUserLoanRequestInitiator, router, data.id);
    });
   }
 };

<DynamicWidthInput
  id="addLoanClause"
  value={addLoanClause}
  type="textarea"
  placeholder="1000 characters"
  error={showErrors && getError("addLoanClause")}
  onChange={e =>
    handleDynamicStateChange(e, setAddLoanClause)
  }
  size={"xxl"}
  rows="5"
/>

How can I achieve it if I want to send empty value in textarea and it will automatically know to send string "None" to the data?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could define your value to be sent using a ternary referencing the length of the input:

const output = addLoanClause.length > 0 ? addLoanClause : 'None'

So if the length of the input is greater than zero, use the input. Else, use 'None'

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda