Skip to content

fix: adds key attribute to help react find dom changes on generated div#1

Open
DeveloperMetal wants to merge 1 commit intoAnurag810:mainfrom
DeveloperMetal:main
Open

fix: adds key attribute to help react find dom changes on generated div#1
DeveloperMetal wants to merge 1 commit intoAnurag810:mainfrom
DeveloperMetal:main

Conversation

@DeveloperMetal
Copy link
Copy Markdown

When you create elements in a loop like the users.map(...) in your code you need to tell react how to target these divs when an update happens.

React doesn't know how or which of these generated divs should be updated if the users state changes. So to help it you need to include the key attribute and pass it a unique id. It can be anything, but must be unique to this loop.

See here for more info: https://reactjs.org/docs/lists-and-keys.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant