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

515
Views
mui TextField in React loosing focus every typing one character after put key props in <div> parent

I have a dynamic component with TextField, but when i put key props in div parent, the TextField always lose focus after typing 1 character, if i delete key props, all normaly. Here my component code.

<div key={uuid()} style={{ display: 'flex', alignItems: 'center', marginBottom: Dimens.px10 }}>
            <TextField
                style={{ marginRight: Dimens.px20 }}
                fullWidth
                required={props.required}
                id="outlined-textarea"
                defaultValue={props.data}
                autoComplete='off'
                label={props.label}
                placeholder={props.label}
                onChange={props.onChange}
            />
            <div style={{
                width: 50,
                maxWidth: 40
            }}>
                <CButton outline isDriver label={<p style={{ fontWeight: 'bold', margin: 0, padding: 0 }}>-</p>} onClick={props.onDeleteClick} />
            </div>
        </div>

How could this happen?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Keys must be stable, <div key={uuid()}> assigns new key.

If they're not stable then React cannot understand that this might be the same as before and then just re-renders. That is the reason if you remove the the key then all works well.

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!