0
0
React Nativemobile~5 mins

FlatList optimization techniques in React Native - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the keyExtractor prop in a FlatList?
The keyExtractor prop provides a unique key for each item in the list. This helps React Native efficiently update and render only changed items, improving performance.
Click to reveal answer
intermediate
Why should you avoid anonymous functions in FlatList's renderItem?
Using anonymous functions inside renderItem causes new functions to be created on every render, which can slow down the list. Instead, define the function outside or use useCallback to memoize it.
Click to reveal answer
beginner
What does the initialNumToRender prop control in FlatList?
It controls how many items are rendered initially when the list loads. Setting it too high can slow startup, too low can cause blank space while scrolling.
Click to reveal answer
intermediate
How does getItemLayout help optimize FlatList?
getItemLayout lets FlatList know the height and position of each item in advance. This avoids measuring on the fly and improves scroll performance.
Click to reveal answer
intermediate
What is the benefit of using React.memo with FlatList item components?
React.memo prevents re-rendering of list items if their props haven't changed. This reduces unnecessary work and makes scrolling smoother.
Click to reveal answer
Which prop helps FlatList identify each item uniquely for better performance?
AonEndReached
BinitialNumToRender
CgetItemLayout
DkeyExtractor
What is a common cause of slow FlatList rendering related to renderItem?
ANot using <code>keyExtractor</code>
BSetting <code>initialNumToRender</code> too low
CUsing anonymous functions inside <code>renderItem</code>
DUsing <code>React.memo</code> on item components
How does getItemLayout improve FlatList performance?
ABy pre-calculating item sizes and positions
BBy rendering all items at once
CBy disabling scrolling
DBy caching images
What does initialNumToRender control?
ANumber of items to skip rendering
BNumber of items rendered initially
CNumber of items to load on scroll end
DNumber of items cached offscreen
Why use React.memo with FlatList items?
ATo prevent unnecessary re-renders when props don't change
BTo force re-render every time
CTo increase initial render count
DTo disable scrolling
Explain how you would optimize a FlatList to improve scrolling performance in a React Native app.
Think about reducing unnecessary renders and helping FlatList know item sizes.
You got /5 concepts.
    Describe the role of the keyExtractor and why it is important for FlatList optimization.
    Keys help React know which items changed or stayed the same.
    You got /4 concepts.