Created
November 14, 2022 14:41
-
-
Save marzuk-zarir/22a74e13c89625d48e6661d14e3e26be to your computer and use it in GitHub Desktop.
React input element losses focus while typing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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