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

177
Views
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
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!