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

160
Views
How to prefilled data in form and the form is editable by using react functional component

This is my react jsx file code overview

const [name, setName] = useState("");
// and the prefield data which I want to be prefield is commit from API which is 
const nameFromApi = userDatails?.name;

// Here is my function return JSX
<input defaultValue={nameFromApi}  value={name} onChange={e => setName(e.target.value)} />
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can initialize name with the value so that will be the initial value of the input

const [name, setName] = useState(userDatails?.name);

<input value={name} onChange={e => setName(e.target.value)} />

about 4 years ago · Juan Pablo Isaza Report

0

If I understand correctly, you are getting a respone from api which is userDatails and you want your input to have the value if userDatails as its initial value?

You can do something like this

const [name, setName] = useState("");

useEffect(()=>{

//call your api and get value

...

setName(userDatails?.name)

},[])
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!