Complete the code to add margin around the View component.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View style={{ margin: [1] }}> <Text>Hello World</Text> </View> ); }
In React Native, margin values are numbers representing density-independent pixels. So, margin: 20 adds 20 units of margin around the View.
Complete the code to add padding inside the View component.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View style={{ padding: [1] }}> <Text>Welcome!</Text> </View> ); }
Padding in React Native is set using numbers without units. So padding: 10 adds 10 units of padding inside the View.
Fix the error in the code to add a red border to the View.
import React from 'react'; import { View, Text } from 'react-native'; export default function App() { return ( <View style={{ borderWidth: 2, borderColor: [1] }}> <Text>Border Example</Text> </View> ); }
In React Native, color values must be strings. So borderColor: 'red' is correct. Without quotes, it causes an error.
Fill both blanks to add padding and margin to the View.
import React from 'react'; import { View, Text } from 'react-native'; export default function App() { return ( <View style={{ padding: [1], margin: [2] }}> <Text>Box with space</Text> </View> ); }
Padding and margin values are numbers without units. So padding: 15 and margin: 10 add space inside and outside the View respectively.
Fill all three blanks to add a blue border, padding, and margin to the View.
import React from 'react'; import { View, Text } from 'react-native'; export default function App() { return ( <View style={{ borderWidth: [1], borderColor: [2], padding: [3] }}> <Text>Styled Box</Text> </View> ); }
Use borderWidth: 3 for thickness, borderColor: 'blue' as a string for color, and padding: 12 as a number for inside space.