Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for List and Keys
Aditya Sharan
Aditya Sharan

Posted on

     

List and Keys

We can output lists using Javascript arrays and the map() function. The map() is used to traverse through an array.

Below is a basic list component that accepts an array of numbers and outputs a list of elements.

Alt Text

  • A key is a special string attribute you need to include when creating lists of elements,as you must have also seen in the last.
  • Keys help React identify which items have changed, or are removed.
  • Keys should be given to the elements inside an array to give the elements a stable identity.

When you don't have stable IDs or a suitable property to be used as key for the rendered items, you may use the item index as a key as last resort :

Alt Text

That's all Thanks for reading !!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Passionately Curious ,Often Wrong , Always Learning ,Fueled By Caffeine ..Always Smiling ! proud owner of an overactive imagination and curious mind.
  • Location
    Bengaluru
  • Pronouns
    He/Him
  • Work
    Software Engineer at Google
  • Joined

More fromAditya Sharan

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp