0
0
React Nativemobile~10 mins

ScrollView component in React Native - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the ScrollView component from React Native.

React Native
import { [1] } from 'react-native';
Drag options to blanks, or click blank then click option'
AText
BScrollView
CView
DButton
Attempts:
3 left
💡 Hint
Common Mistakes
Importing View instead of ScrollView.
Forgetting to import ScrollView.
2fill in blank
medium

Complete the code to wrap content inside a ScrollView component.

React Native
return (
  <[1]>
    <Text>Scrollable content</Text>
  </[1]>
);
Drag options to blanks, or click blank then click option'
AScrollView
BFlatList
CSafeAreaView
DView
Attempts:
3 left
💡 Hint
Common Mistakes
Using View which does not scroll.
Using FlatList which is for lists, not simple scroll.
3fill in blank
hard

Fix the error in the ScrollView usage by completing the missing prop to enable horizontal scrolling.

React Native
<ScrollView [1]>
  <Text>Swipe horizontally</Text>
</ScrollView>
Drag options to blanks, or click blank then click option'
Avertical={true}
BpagingEnabled={false}
CscrollEnabled={false}
Dhorizontal={true}
Attempts:
3 left
💡 Hint
Common Mistakes
Using vertical prop which does not exist.
Disabling scroll with scrollEnabled={false}.
4fill in blank
hard

Fill both blanks to create a ScrollView with a fixed height and enable vertical scrolling.

React Native
const styles = StyleSheet.create({
  container: {
    height: [1],
    backgroundColor: 'lightgray'
  }
});

return (
  <ScrollView style={styles.container} [2]>
    <Text>Lots of content here</Text>
  </ScrollView>
);
Drag options to blanks, or click blank then click option'
A300
Bhorizontal={true}
CscrollEnabled={true}
Dflex: 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex: 1 for height which fills all space instead of fixed height.
Setting horizontal={true} when vertical scroll is needed.
5fill in blank
hard

Fill all three blanks to create a ScrollView that scrolls horizontally, hides the scroll indicator, and snaps to page.

React Native
<ScrollView [1] [2] [3]>
  <View style={{width: 300, height: 200, backgroundColor: 'red'}} />
  <View style={{width: 300, height: 200, backgroundColor: 'blue'}} />
</ScrollView>
Drag options to blanks, or click blank then click option'
Ahorizontal={true}
BshowsHorizontalScrollIndicator={false}
CpagingEnabled={true}
DscrollEnabled={false}
Attempts:
3 left
💡 Hint
Common Mistakes
Disabling scroll with scrollEnabled={false}.
Not hiding the scroll indicator when asked.