Sample questions
Question 1Easy
Why is FlatList preferred over mapping a large array inside a ScrollView?
- It renders all items faster using native threads
- It virtualizes, rendering only items near the screen
- It caches every item's image on disk automatically
- It sorts and de-duplicates the data before rendering
Answer: B. It virtualizes, rendering only items near the screen
Explanation
FlatList renders a window of items around the viewport and unmounts far-away ones, keeping memory and render time low for long lists.
Step-by-step solution
- FlatList renders only the items near the visible window.
- A ScrollView with mapped children renders every item at once.
- So FlatList is better for long lists because it virtualizes, which is option B.
Why the other options are wrong
- A. FlatList does not use native threads to render every item faster.
- C. FlatList does not cache images on disk.
- D. FlatList does not sort or remove duplicates from the data.
Tip: Use FlatList for long lists because it renders only the items on or near the screen.
Question 2Easy
Which FlatList prop makes the list scroll sideways?
- direction="x"
- flexDirection="row"
- horizontal
- sideways
Answer: C. horizontal
Explanation
Setting horizontal renders items in a row and scrolls horizontally.
Step-by-step solution
- The horizontal prop makes a FlatList lay items out in a row and scroll sideways.
- The other options are not FlatList props for sideways scrolling.
- So the correct prop is option C, horizontal.
Why the other options are wrong
- A. Direction is not a FlatList prop.
- B. FlexDirection is a style property and does not make the list scroll.
- D. Sideways is not a FlatList prop.
Tip: Set horizontal on FlatList or ScrollView to scroll sideways.
Question 3Easy
Which FlatList prop renders something when the data array is empty?
- ListFooterComponent
- renderEmpty
- ListEmptyComponent
- emptyText
Answer: C. ListEmptyComponent
Explanation
ListEmptyComponent is shown when data has no items, for example an 'No results' message.
Step-by-step solution
- ListEmptyComponent is shown when the data array has no items.
- It is the prop meant for an empty state, such as a No results message.
- So the correct prop is option C, ListEmptyComponent.
Why the other options are wrong
- A. ListFooterComponent renders at the end of the list, even when it has items.
- B. RenderEmpty is not a FlatList prop.
- D. EmptyText is not a FlatList prop.
Tip: Use ListEmptyComponent for the empty state and ListFooterComponent for content after the items.
Question 4Easy
Which two props must you pass to a FlatList?
- data and renderItem
- items and keyExtractor
- data and children
- source and renderRow
Answer: A. data and renderItem
Explanation
data supplies the array and renderItem returns the element for each item. keyExtractor is strongly recommended but optional.
Step-by-step solution
- FlatList needs data and renderItem.
Why the other options are wrong
- B. items is not a prop.
- C. It does not take children.
- D. source and renderRow are old.
Tip: data + renderItem.
Question 5Medium
Every row in a FlatList is exactly 80 units tall. What should getItemLayout return for a given index?
- { height: 80, top: index, index }
- { length: 80 * index, offset: 80, index }
- { length: 80, offset: 80 * index, index }
- { length: 80, offset: 80 + index, index }
Answer: C. { length: 80, offset: 80 * index, index }
Explanation
length is the item's size and offset is its distance from the start. With fixed heights, offset is size times index, so FlatList can skip measuring.
Step-by-step solution
- GetItemLayout returns the length, the offset from the start, and the index.
- Each row is 80 tall, so length is 80.
- The offset of row index is 80 times index, because each earlier row adds 80.
- So the return value is length 80 and offset 80 times index, which is option C.
Why the other options are wrong
- A. Height and top are not the keys getItemLayout returns; length and offset are.
- B. The length must be the row size 80, not 80 times the index.
- D. The offset must be 80 times the index, not 80 plus the index.
Tip: With fixed row heights, getItemLayout gives length as the row height and offset as height times index.
Question 6Medium
Why is a row component often wrapped in React.memo when used in renderItem?
- So the row is rendered on a background native thread
- So each row is cached to disk between app launches
- So rows whose props did not change skip re-rendering
- So FlatList can render the row before its data arrives
Answer: C. So rows whose props did not change skip re-rendering
Explanation
When the list re-renders, memoised rows with unchanged props are skipped, cutting a lot of work on long lists.
Step-by-step solution
- React.memo skips re-rendering a component when its props have not changed.
- When the list re-renders, memoised rows with the same props are skipped.
- That saves work on long lists, so the answer is option C.
Why the other options are wrong
- A. Rows render on the JS thread, and memo does not move them to a native thread.
- B. Memo does not cache rows to disk between launches.
- D. Rows are rendered when their data is available, and memo does not change that.
Tip: Use React.memo on rows, and keep the props stable, so unchanged rows are skipped.
Question 7Medium
What is the benefit of providing getItemLayout to a FlatList?
- It lets rows have different random heights each render
- It skips measuring rows, so scrollToIndex works fast
- It makes FlatList render every item at once
- It replaces the need for keys on each item
Answer: B. It skips measuring rows, so scrollToIndex works fast
Explanation
When item sizes are known up front, FlatList can compute positions instantly, which speeds up rendering and allows jumping to far indexes.
Step-by-step solution
- getItemLayout tells FlatList each row's size and position.
- It skips measuring rows.
- So scrollToIndex is fast.
Why the other options are wrong
- A. It assumes known heights.
- C. It does not disable virtualisation.
- D. Keys are still needed.
Tip: Fixed height -> getItemLayout.
Question 8Medium
If a FlatList has no keyExtractor, which key does it use for each item by default?
- Always the item's array index
item.key, then item.id, then the index- A random id per render
JSON.stringify(item)
Answer: B. item.key, then item.id, then the index
Explanation
The default extractor checks item.key, then item.id, and falls back to the index, which can cause bugs when items move.
Step-by-step solution
- Without a keyExtractor, FlatList checks item.key first.
- If item.key is missing, it checks item.id next.
- If neither exists, it falls back to the index, so the answer is option B.
Why the other options are wrong
- A. The index is only the last fallback, after item.key and item.id.
- C. The key is not random; it comes from the item or the index.
- D. JSON.stringify of the item is not the default key.
Tip: Pass keyExtractor to FlatList when items have no key or id, so keys stay stable when rows move.
Question 9Hard
What does FlatList's windowSize prop control?
- How many items are drawn in the very first batch
- The pixel size of the scroll area on the screen
- How many rows are fetched from the network at once
- How many screen-lengths of content stay rendered
Answer: D. How many screen-lengths of content stay rendered
Explanation
windowSize is measured in units of the visible length. Larger windows mean fewer blank areas when scrolling fast but more memory.
Step-by-step solution
- WindowSize sets how much content stays rendered around the visible area.
- It is measured in multiples of the visible length, so a larger value keeps more content rendered around the screen.
- So windowSize is how many screen-lengths of content stay rendered, which is option D.
Why the other options are wrong
- A. The first batch size is set by initialNumToRender, not windowSize.
- B. WindowSize is a multiple of the visible length, not a pixel size.
- C. Network fetching is not controlled by windowSize.
Tip: A larger windowSize means fewer blank areas when scrolling fast, but uses more memory.
Question 10Hard
renderItem highlights the row whose id equals selectedId (a state variable that is not in data). Rows don't update when selectedId changes. What fixes it?
- Pass
extraData={selectedId} to the FlatList - Pass
selectedId inside the keyExtractor function - Call
forceUpdate() inside every renderItem call - Wrap the FlatList in a ScrollView to re-render it
Answer: A. Pass extraData={selectedId} to the FlatList
Explanation
FlatList is a pure component that re-renders only when its props change. extraData tells it about outside values that renderItem depends on.
Step-by-step solution
- FlatList re-renders only when its props change.
- SelectedId is not in data or in any prop, so the list does not know it changed.
- extraData={selectedId} tells FlatList to re-render when that value changes.
- So the fix is option A.
Why the other options are wrong
- B. KeyExtractor is for keys; putting selectedId there does not make the list re-render.
- C. ForceUpdate is not used in function components, and calling it inside renderItem is not the fix.
- D. Wrapping in a ScrollView does not tell FlatList about the new selectedId.
Tip: Pass every outside value that renderItem reads to extraData.
Practise all 16 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →