0
0
Reactframework~5 mins

Rendering lists in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the key prop when rendering lists in React?
The key prop helps React identify which items have changed, been added, or removed. It improves performance by allowing React to update only the necessary elements in the list.
Click to reveal answer
beginner
How do you render a list of items in React?
You use the JavaScript map() method on an array to create an array of React elements. Each element should have a unique key prop.
Click to reveal answer
intermediate
Why should list keys be unique and stable?
Keys must be unique and stable so React can correctly match elements between renders. Using indexes as keys can cause bugs if the list changes order or items are added/removed.
Click to reveal answer
beginner
What happens if you forget to add a key prop to list items in React?
React will show a warning in the console. Without keys, React may re-render list items inefficiently, causing performance issues or unexpected UI behavior.
Click to reveal answer
intermediate
Can you use any value as a key in React lists? What should you avoid?
You can use any unique and stable value as a key, like an ID from your data. Avoid using array indexes as keys if the list can change, because it can cause UI bugs.
Click to reveal answer
What React method is commonly used to render a list of items?
Afilter()
Bmap()
Creduce()
DforEach()
Why is the key prop important in list rendering?
AIt sorts the list items
BIt styles the list items
CIt adds event listeners automatically
DIt helps React track items for efficient updates
Which of these is a bad choice for a React list key?
AArray index when list changes
BUnique user ID
CStable product code
DUUID string
What will React do if list items lack a key prop?
AShow a warning in the console
BAutomatically generate keys
CIgnore the list
DCrash the app
Which is the best practice for keys in React lists?
AUse array indexes always
BUse random numbers each render
CUse unique and stable IDs from data
DUse the item’s display text
Explain how to render a list of items in React and why the key prop is necessary.
Think about how React knows which items changed.
You got /3 concepts.
    Describe what can go wrong if you use array indexes as keys in React lists.
    Imagine rearranging or adding items in a list.
    You got /3 concepts.