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

187
Vistas
React final form, populate input from API, but still allow user to override it

I have a input in react final field. The user can input their own value. Theres an option to do something in the form, which makes an api call, and stores the data in state. If that is an option, we populate the input with that value.

However I want to user to be able to override that value. If the API call is made again, I want the value to replace the current input, but still be able to be overiden.

I can't fully delete the value from the api, it won't let me delete all of it and override the data.

File where I render the input, and state is handled.

  function RenderFilter(index: number) {
  const apiValue = dataFromAPI;
  return <TextBox key={index} value1={apiValue ? apiValue.value : null} />;
}

TextBox.jsx

import { Field } from 'react-final-form';

export interface IInput {
  name: string;
  value1: string;
}

function TextBox({ name, value1 }: IInput) {
  return (
    <Field name={name}>
      {({ input }) => (
        <>
          <input
            name={input.name}
            value={input.value}
            onChange={input.onChange}
          />
          {value1 && input.onChange(value1)}
        </>
      )}
    </Field>
  );
}

export { TextBox };

Any ideas?

about 4 years ago · Juan Pablo Isaza
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