Recall & Review
beginner
What is a callback prop in React Native?
A callback prop is a function passed from a parent component to a child component. The child calls this function to send data or notify the parent about events.
Click to reveal answer
beginner
Why do we use callback props in React Native?
We use callback props to let child components communicate with their parents, especially to send data or trigger actions in the parent.Click to reveal answer
beginner
How do you define a callback prop in a parent component?
You define a function in the parent and pass it as a prop to the child component, like <Child onPress={handlePress} />.
Click to reveal answer
beginner
How does a child component use a callback prop?
The child calls the function received as a prop, for example props.onPress(), to notify or send data back to the parent.
Click to reveal answer
intermediate
What happens if a callback prop is not passed to a child component?
If the child tries to call the callback but it is not passed, it can cause an error. It's good to check if the prop exists before calling it.
Click to reveal answer
What is the main purpose of a callback prop in React Native?
✗ Incorrect
Callback props let child components communicate with parents by sending data or events.
How do you pass a callback prop from a parent to a child component?
✗ Incorrect
You pass the function as a prop, often named to describe the event, like callback or onPress.
In the child component, how do you call the callback prop named onPress?
✗ Incorrect
The child calls the function from props using props.onPress() to notify the parent.
What should you do before calling a callback prop in a child component?
✗ Incorrect
Checking if the callback exists prevents errors if the parent did not pass it.
Which of these is NOT a reason to use callback props?
✗ Incorrect
Styling is usually passed as style props, not callback functions.
Explain how callback props enable communication between parent and child components in React Native.
Think about how a child tells the parent something happened.
You got /3 concepts.
Describe the steps to safely use a callback prop in a child component.
Avoid errors by verifying the callback before calling.
You got /3 concepts.