0
What problems can occur when array indexes are used as keys in React?
subina kallyani
easy
0completed
0
Answer
Using array indexes as keys in React can lead to incorrect UI updates and performance issues, especially when the list changes.
React uses keys to identify list items. When indexes are used, the identity of items can break if the list is modified.
Why this is a problem
Array indexes change when:
- Items are added
- Items are removed
- Items are reordered
Because of this, React may:
- Reuse the wrong component
- Preserve incorrect state
- Re-render items unnecessarily
Issues Caused :
- Wrong data shown in UI
- Input fields lose or mix values
- Bugs that are hard to debug
- Poor rendering performance
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0