Complete the code to create a simple style object using StyleSheet.
import { StyleSheet } from 'react-native'; const styles = StyleSheet.[1]({ container: { flex: 1, backgroundColor: 'white', }, });
The StyleSheet.create method is used to define styles in React Native. It helps with performance and validation.
Complete the code to add a text style with font size 20.
const styles = StyleSheet.create({
text: {
fontSize: [1],
},
});In React Native, numeric values for sizes like fontSize are numbers, not strings with units.
Fix the error in the style property name to set background color.
const styles = StyleSheet.create({
box: {
[1]: 'blue',
},
});The correct style property for background color in React Native is backgroundColor.
Fill both blanks to create a style with margin 10 and padding 5.
const styles = StyleSheet.create({
box: {
[1]: 10,
[2]: 5,
},
});margin sets space outside the box, and padding sets space inside the box around content.
Fill all three blanks to create a style with flex 1, justifyContent center, and alignItems center.
const styles = StyleSheet.create({
container: {
[1]: 1,
[2]: 'center',
[3]: 'center',
},
});flex controls the size ratio, justifyContent centers items horizontally, and alignItems centers items vertically in a flex container.