0
0
Reactframework~5 mins

Importance of keys in React - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of keys in React lists?
Keys help React identify which items have changed, been added, or removed. This makes updating the UI faster and more efficient.
Click to reveal answer
beginner
Why should keys be unique among siblings in a list?
Unique keys prevent confusion when React compares elements. If keys are not unique, React might update the wrong item, causing bugs.
Click to reveal answer
intermediate
What can happen if you use the array index as a key in React?
Using array index as a key can cause problems when the list changes order or items are added/removed. React may reuse elements incorrectly, leading to UI bugs.
Click to reveal answer
beginner
How do keys improve React's rendering performance?
Keys let React quickly find which elements changed without re-rendering the entire list. This reduces work and speeds up updates.
Click to reveal answer
intermediate
Can two different lists share the same keys for their items?
Yes, keys only need to be unique among siblings in the same list. Different lists can reuse keys without issues.
Click to reveal answer
Why does React require keys for list items?
ATo style the list items differently
BTo track which items changed for efficient updates
CTo add animations automatically
DTo sort the list alphabetically
What is a bad practice when assigning keys in React?
AUsing unique IDs from data
BUsing strings as keys
CUsing keys only among siblings
DUsing array index as key when list changes
Keys must be unique among which elements?
ASibling elements in the same list
BAll lists in the app
CAll components in the app
DParent components only
What happens if keys are missing in a React list?
AReact updates the list less efficiently and may cause bugs
BNothing, keys are optional
CReact automatically generates unique keys
DReact throws an error and stops rendering
Can two different lists use the same keys for their items?
AOnly if the lists are rendered at different times
BNo, keys must be unique app-wide
CYes, keys only need to be unique among siblings
DOnly if the lists have the same length
Explain why keys are important in React lists and what problems they help avoid.
Think about how React updates the screen when list items change.
You got /4 concepts.
    Describe the risks of using array index as a key in React and when it might cause bugs.
    Consider what happens if you reorder or add items in a list.
    You got /4 concepts.