Skip to content

Instantly share code, notes, and snippets.

@marzuk-zarir
Created November 14, 2022 14:41
Show Gist options
  • Select an option

  • Save marzuk-zarir/22a74e13c89625d48e6661d14e3e26be to your computer and use it in GitHub Desktop.

Select an option

Save marzuk-zarir/22a74e13c89625d48e6661d14e3e26be to your computer and use it in GitHub Desktop.
React input element losses focus while typing.
It is only happens when we loop over an array and render an input component with different key prop every time. When render the input component react see that I have a different key so he render the whole a new component on vdom. So, we can easily solve this problem by passing the same key (index of an array instead of uuid or something like this) every time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment