0
0
React Nativemobile~10 mins

Children prop 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 render the children inside the Box component.

React Native
function Box(props) {
  return <View>{props.[1]</View>;
}
Drag options to blanks, or click blank then click option'
Aelements
Bcontent
Citems
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong prop name like content or items instead of children.
Trying to access children without props.
2fill in blank
medium

Complete the code to wrap the children with a Text component inside the Wrapper.

React Native
function Wrapper([1]) {
  return <Text>{children}</Text>;
}
Drag options to blanks, or click blank then click option'
Achildren
Bcontent
Cprops
Delements
Attempts:
3 left
💡 Hint
Common Mistakes
Destructuring a wrong prop name.
Not destructuring and trying to use children directly.
3fill in blank
hard

Fix the error in the code to correctly render children inside the container.

React Native
const Container = (props) => {
  return <View>[1]</View>;
};
Drag options to blanks, or click blank then click option'
Aprops.children()
Bprops.child
Cprops.children
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Calling children as a function like props.children().
Using a wrong prop name like props.child.
4fill in blank
hard

Fill both blanks to create a component that adds padding around its children.

React Native
function PaddedBox([1]) {
  return <View style={{ padding: 10 }}>{ [2] }</View>;
}
Drag options to blanks, or click blank then click option'
Achildren
Bcontent
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using different prop names for destructuring and rendering.
Forgetting to render children inside the View.
5fill in blank
hard

Fill all three blanks to create a component that conditionally wraps children with a border.

React Native
function BorderWrapper([1], [2]) {
  return (
    <View style={{ borderWidth: [3], borderColor: 'black' }}>
      {children}
    </View>
  );
}
Drag options to blanks, or click blank then click option'
Achildren
BhasBorder
C2
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Not destructuring all props correctly.
Using a boolean instead of a number for borderWidth.