0
0
React Nativemobile~10 mins

Skeleton loading screens 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 React Native component used to create a skeleton placeholder.

React Native
import { [1] } from 'react-native';
Drag options to blanks, or click blank then click option'
ASkeletonPlaceholder
BImage
CText
DView
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import a non-existent SkeletonPlaceholder component from react-native.
Using Text or Image instead of View for the skeleton container.
2fill in blank
medium

Complete the code to create a simple skeleton block with a gray background and rounded corners.

React Native
const SkeletonBlock = () => {
  return <View style={{ backgroundColor: '[1]', borderRadius: 8, height: 20, width: 100 }} />;
};
Drag options to blanks, or click blank then click option'
A#CCCCCC
B#FFFFFF
C#000000
D#FF0000
Attempts:
3 left
💡 Hint
Common Mistakes
Using white (#FFFFFF) which blends with the background.
Using black (#000000) which is too dark for skeletons.
3fill in blank
hard

Fix the error in the code to animate the skeleton block's opacity using React Native's Animated API.

React Native
const opacity = new Animated.Value(1);

Animated.loop(
  Animated.sequence([
    Animated.timing(opacity, { toValue: [1], duration: 500, useNativeDriver: true }),
    Animated.timing(opacity, { toValue: 1, duration: 500, useNativeDriver: true })
  ])
).start();
Drag options to blanks, or click blank then click option'
A2
B0
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using values greater than 1 or negative values for opacity.
Setting toValue to 1 which causes no fade effect.
4fill in blank
hard

Fill both blanks to create a skeleton screen with two blocks stacked vertically with spacing.

React Native
return (
  <View style={{ padding: 16 }}>
    <View style={{ height: 20, width: 150, backgroundColor: '[1]', borderRadius: 4 }} />
    <View style={{ height: 20, width: 100, backgroundColor: '[2]', borderRadius: 4, marginTop: 12 }} />
  </View>
);
Drag options to blanks, or click blank then click option'
A#E0E0E0
B#FFFFFF
C#B0B0B0
D#000000
Attempts:
3 left
💡 Hint
Common Mistakes
Using white which makes blocks invisible.
Using black which is too harsh for skeletons.
5fill in blank
hard

Fill all three blanks to create a skeleton screen with a circle avatar and two text lines below.

React Native
return (
  <View style={{ flexDirection: '[1]', alignItems: 'center', padding: 16 }}>
    <View style={{ height: 60, width: 60, borderRadius: [2], backgroundColor: '#CCC' }} />
    <View style={{ marginLeft: 16, flexDirection: '[3]' }}>
      <View style={{ height: 20, width: 120, backgroundColor: '#DDD', borderRadius: 4, marginBottom: 8 }} />
      <View style={{ height: 20, width: 80, backgroundColor: '#DDD', borderRadius: 4 }} />
    </View>
  </View>
);
Drag options to blanks, or click blank then click option'
Arow
B30
Ccolumn
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Using flexDirection 'column' which stacks avatar and text vertically.
Setting borderRadius equal to height or width instead of half.