0
0
Reactframework~5 mins

Keys concept in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of keys in React lists?
Keys help React identify which items have changed, been added, or removed. They make updates faster and keep UI consistent.
Click to reveal answer
beginner
Why should keys be unique among siblings in a list?
Unique keys prevent React from mixing up elements. If keys repeat, React may reuse wrong elements causing bugs.
Click to reveal answer
intermediate
Is using array index as a key always a good idea? Why or why not?
Using index as key is okay only if list items never change order or get removed. Otherwise, it can cause wrong UI updates.
Click to reveal answer
beginner
What happens if you forget to add keys to list items in React?
React will warn you in the console. Without keys, React can't track items well, leading to slower updates and possible UI glitches.
Click to reveal answer
intermediate
How do keys affect React's reconciliation process?
Keys let React match old and new elements during reconciliation. This helps React update only changed parts efficiently.
Click to reveal answer
What should a key in a React list be?
AUnique among siblings
BThe same for all items
CA random number every render
DAlways the array index
What is a risk of using array index as a key when list items change order?
AReact may reuse wrong elements causing UI bugs
BNo risk, it's always safe
CIt makes React slower
DIt causes syntax errors
If you forget keys in a list, what will React do?
ACrash the app
BShow a warning in the console
CAutomatically add keys
DIgnore the list
Keys help React to:
AStyle the list items
BFetch data from server
CHandle user input
DIdentify which items changed during updates
Which of these is a good choice for a key?
ARandom number generated on render
BCurrent timestamp
CUser ID from database
DArray index when list changes often
Explain why keys are important in React lists and what can go wrong if keys are missing or not unique.
Think about how React updates list items efficiently.
You got /4 concepts.
    Describe when it is okay and not okay to use array index as a key in React lists.
    Consider what happens when list items move around.
    You got /3 concepts.