React list "Key"

SUNGHEE KIM·2022년 5월 26일
0

When you make a list in JSX, sometimes your list will need to include something called keys:


A key is a JSX attribute. The attribute’s name is key. The attribute’s value should be something unique, similar to an id attribute.

keys don’t do anything that you can see! React uses them internally to keep track of lists. If you don’t use keys when you’re supposed to, React might accidentally scramble your list-items into the wrong order.

map()에서 두번째 parameter로 i를 만들면 li에서 key 만들수 있고, li에 key attribute를 넣으면 됨

0개의 댓글