What is the purpose of the ScrollView component in React Native?
The ScrollView component allows users to scroll through a list or content that is larger than the screen size, enabling vertical or horizontal scrolling.
Click to reveal answer
beginner
How do you enable horizontal scrolling in a ScrollView?
Set the horizontal prop to true on the ScrollView component to enable horizontal scrolling.
Click to reveal answer
intermediate
What prop would you use to add padding inside a ScrollView content area?
You can use the contentContainerStyle prop to style the inner content container, including adding padding.
Click to reveal answer
intermediate
Why should you avoid putting very large lists inside a ScrollView?
Because ScrollView renders all its child components at once, which can cause performance issues with very large lists. For large lists, use FlatList or SectionList instead.
Click to reveal answer
advanced
How can you make a ScrollView accessible for keyboard navigation?
Ensure the ScrollView has proper accessibility props like accessible and use focusable child components. Also, test keyboard navigation to confirm smooth scrolling and focus behavior.
Click to reveal answer
Which prop enables horizontal scrolling in a React Native ScrollView?
AscrollDirection="horizontal"
BenableHorizontalScroll
Cdirection="horizontal"
Dhorizontal={true}
✗ Incorrect
The correct prop is horizontal={true} to enable horizontal scrolling.
What happens if you put a very large list inside a ScrollView?
AIt only renders visible items for better performance.
BIt automatically paginates the list.
CIt renders all items at once, which may slow down the app.
DIt converts the list to a FlatList automatically.
✗ Incorrect
ScrollView renders all children at once, which can cause performance issues with large lists.
Which prop do you use to style the inner content container of a ScrollView?
AcontentStyle
BcontentContainerStyle
Cstyle
DinnerStyle
✗ Incorrect
Use contentContainerStyle to style the inner content container of a ScrollView.
How do you make a ScrollView scroll vertically by default?
ANo prop needed; vertical is default
BSet scrollDirection="vertical"
CSet vertical={true}
DSet direction="vertical"
✗ Incorrect
Vertical scrolling is the default behavior of ScrollView.
Which component is better for rendering very long lists efficiently in React Native?
AFlatList
BText
CView
DScrollView
✗ Incorrect
FlatList is optimized for large lists by rendering only visible items.
Explain how to use the ScrollView component to create a vertically scrollable list of items.
Think about wrapping your content inside <code><ScrollView></code> tags.
You got /4 concepts.
Describe the difference between ScrollView and FlatList and when to use each.
Consider performance and list size.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of the ScrollView component in React Native?
easy
A. To manage app navigation between screens
B. To allow users to scroll content that is larger than the screen
C. To display images only
D. To create buttons for user interaction
Solution
Step 1: Understand ScrollView's role
The ScrollView component is designed to let users scroll through content that does not fit on the screen.
Step 2: Compare options
Options A, B, and C describe other components or features, not ScrollView.
Final Answer:
To allow users to scroll content that is larger than the screen -> Option B
Quick Check:
ScrollView = scrolls content [OK]
Hint: ScrollView scrolls content bigger than screen [OK]
Common Mistakes:
Confusing ScrollView with navigation components
Thinking ScrollView only displays images
Assuming ScrollView creates buttons
2. Which of the following is the correct way to make a ScrollView scroll horizontally?
easy
A. ...
B. ...
C. ...
D. ...
Solution
Step 1: Recall ScrollView horizontal prop
ScrollView uses the horizontal boolean prop to enable horizontal scrolling.
Step 2: Check syntax correctness
Only ... uses the correct prop name and value syntax. Others use invalid or non-existent props.
Final Answer:
<ScrollView horizontal={true}>...</ScrollView> -> Option C
Quick Check:
horizontal={true} enables horizontal scroll [OK]
Hint: Use horizontal={true} prop for horizontal scroll [OK]
Common Mistakes:
Using wrong prop names like scrollDirection or direction
Forgetting to set horizontal to true
Using shorthand props incorrectly
3. What will be the visible behavior of this code snippet?
import React from 'react';
import { ScrollView, Text } from 'react-native';
export default function App() {
return (
{[...Array(20)].map((_, i) => (
Item {i + 1}
))}
);
}
medium
A. A vertical list of 20 text items that can be scrolled up and down
B. A horizontal list of 20 text items that can be scrolled left and right
C. Only the first 5 items are visible, no scrolling possible
D. App will crash due to missing keys in list items
Solution
Step 1: Analyze ScrollView default behavior
ScrollView scrolls vertically by default, so the list will scroll up and down.
Step 2: Check list rendering and keys
The code uses keys correctly with key={i} and renders 20 Text items inside ScrollView.
Final Answer:
A vertical list of 20 text items that can be scrolled up and down -> Option A
Quick Check:
ScrollView default = vertical scroll [OK]
Hint: ScrollView scrolls vertically by default [OK]
Common Mistakes:
Assuming horizontal scroll without horizontal prop
Thinking keys are missing causing crash
Believing only a few items show without scroll
4. Identify the error in this ScrollView usage:
import React from 'react';
import { ScrollView, Text } from 'react-native';
export default function App() {
return (
Item 1
Item 2
);
}
medium
A. Missing key props on Text components
B. Text components cannot be children of ScrollView
C. ScrollView requires a style prop to work
D. The horizontal prop should be a boolean, not a string
Solution
Step 1: Check horizontal prop type
The horizontal prop expects a boolean value, but "true" is a string here, which is incorrect.
Step 2: Verify other props and children
Text components are valid children, style is optional, and keys are not required for static children.
Final Answer:
The horizontal prop should be a boolean, not a string -> Option D
Quick Check:
horizontal must be boolean, not string [OK]
Hint: Pass boolean true, not string "true" for horizontal [OK]
Common Mistakes:
Using string "true" instead of boolean true
Thinking keys are needed for static children
Assuming style prop is mandatory
5. You want to display a list of 50 images horizontally scrollable inside a ScrollView. Which approach is best to ensure good performance and user experience?
hard
A. Use FlatList horizontal={true} to render images lazily
B. Use ScrollView without horizontal prop and render images vertically
C. Use ScrollView horizontal={true} with all 50 images rendered inside
D. Use View with manual scrolling logic
Solution
Step 1: Understand ScrollView limits
ScrollView renders all children at once, which can hurt performance with many items like 50 images.
Step 2: Choose better component for large lists
FlatList supports lazy loading and virtualization, improving performance for large lists and supports horizontal scrolling.
Step 3: Evaluate other options
Use ScrollView without horizontal prop and render images vertically scrolls vertically, not horizontal as required. Use View with manual scrolling logic requires complex manual logic and is not recommended.
Final Answer:
Use <FlatList horizontal={true}> to render images lazily -> Option A
Quick Check:
FlatList = best for large scrollable lists [OK]
Hint: Use FlatList for large scrollable lists, not ScrollView [OK]
Common Mistakes:
Using ScrollView for large lists causing slow performance
Ignoring horizontal prop for horizontal scroll
Trying manual scroll logic instead of built-in components
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.