Complete the code to import the React Native component used to create a skeleton placeholder.
import { [1] } from 'react-native';
The View component is the basic building block in React Native and is used to create skeleton placeholders by styling.
Complete the code to create a simple skeleton block with a gray background and rounded corners.
const SkeletonBlock = () => {
return <View style={{ backgroundColor: '[1]', borderRadius: 8, height: 20, width: 100 }} />;
};The color #CCCCCC is a light gray, commonly used for skeleton loading blocks to indicate loading content.
Fix the error in the code to animate the skeleton block's opacity using React Native's Animated API.
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();
The opacity value must be between 0 and 1. Setting toValue to 0 fades out the skeleton block.
Fill both blanks to create a skeleton screen with two blocks stacked vertically with spacing.
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> );
Using #E0E0E0 and #B0B0B0 creates two shades of gray for a subtle skeleton effect with spacing.
Fill all three blanks to create a skeleton screen with a circle avatar and two text lines below.
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> );
Setting flexDirection to row arranges avatar and text side by side. The avatar's borderRadius is half its size (30) to make it a circle. The text container uses column to stack lines vertically.