Bird
Raised Fist0
React Nativemobile~20 mins

Props passing in React Native - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Props Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate
2:00remaining
What will be displayed by this component?
Consider this React Native component that receives a prop called name. What text will it show on the screen?
React Native
function Greeting(props) {
  return <Text>Hello, {props.name}!</Text>;
}

// Usage:
<Greeting name="Alice" />
AError: props is undefined
BHello, props.name!
CHello, Alice!
DHello, !
Attempts:
2 left
💡 Hint
Props are used to pass data from parent to child components.
📝 Syntax
intermediate
2:00remaining
Which option correctly passes multiple props?
You want to pass two props, title and count, to a component. Which usage is correct?
React Native
function Info(props) {
  return <Text>{props.title}: {props.count}</Text>;
}
A<Info title="Messages" count={5} />
B<Info title="Messages" count=5 />
C<Info title={"Messages"} count="5" />
D<Info title=Messages count=5 />
Attempts:
2 left
💡 Hint
Use curly braces for numbers and quotes for strings in JSX props.
❓ lifecycle
advanced
2:00remaining
What happens if a prop changes in a functional component?
If a parent component passes a prop color to a child functional component, what happens when color changes?
AThe child component re-renders with the new prop value.
BThe child component ignores the change and keeps old value.
CThe child component unmounts and remounts.
DThe app crashes with an error.
Attempts:
2 left
💡 Hint
React updates components when props change to keep UI in sync.
🔧 Debug
advanced
2:00remaining
Why does this component show 'undefined' for a prop?
This component tries to show props.message but displays 'undefined'. What is the likely cause?
React Native
function ShowMessage(props) {
  return <Text>{message}</Text>;
}

// Usage:
<ShowMessage message="Hi!" />
AThe component must use state to show props.
BThe prop 'message' was not passed from parent.
CReact Native Text component cannot display props.
DThe component uses 'message' instead of 'props.message'.
Attempts:
2 left
💡 Hint
Inside the component, you must access props with 'props.' prefix.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of passing props in React Native?
Why do React Native components use props to receive data instead of using global variables?
AProps automatically update the database with new values.
BProps make components reusable and predictable by passing data explicitly.
CProps allow components to change global variables directly.
DProps prevent components from rendering multiple times.
Attempts:
2 left
💡 Hint
Think about how data flows in React apps and why explicit data passing is helpful.

Practice

(1/5)
1. What is the main purpose of props in React Native components?
easy
A. To style components with CSS
B. To store internal state of a component
C. To pass data from a parent component to a child component
D. To handle user input events

Solution

  1. Step 1: Understand the role of props

    Props are used to send data from a parent component down to its children, allowing dynamic content.
  2. Step 2: Differentiate props from state and styling

    State holds internal data, styling is separate, and event handling is done via callbacks, not props alone.
  3. Final Answer:

    To pass data from a parent component to a child component -> Option C
  4. Quick Check:

    Props = Data passing from parent to child [OK]
Hint: Props always flow from parent to child components [OK]
Common Mistakes:
  • Confusing props with state
  • Thinking props handle styling
  • Assuming props manage events directly
2. Which of the following is the correct way to pass a prop named title with value "Hello" to a component Greeting?
easy
A.
B.
C.
D.

Solution

  1. Step 1: Recognize JSX prop syntax

    Props with string values must be passed inside quotes like title="Hello".
  2. Step 2: Identify incorrect syntax

    Using curly braces without quotes expects a variable, missing quotes or equals sign is invalid.
  3. Final Answer:

    <Greeting title="Hello" /> -> Option A
  4. Quick Check:

    String props need quotes in JSX [OK]
Hint: Use quotes for string props in JSX [OK]
Common Mistakes:
  • Omitting quotes around string values
  • Using curly braces for plain strings
  • Missing equals sign between prop and value
3. What will be displayed on the screen when this code runs?
function Welcome(props) {
  return {props.message};
}

export default function App() {
  return ;
}
medium
A. props.message
B. Error: message not defined
C. Welcome
D. Hi there!

Solution

  1. Step 1: Identify prop usage in Welcome component

    The Welcome component receives message prop and displays it inside Text.
  2. Step 2: Check what prop value is passed

    The App component passes message="Hi there!" to Welcome.
  3. Final Answer:

    Hi there! -> Option D
  4. Quick Check:

    Props value shown in child component [OK]
Hint: Props values appear where used inside child components [OK]
Common Mistakes:
  • Printing the prop name instead of its value
  • Expecting component name to display
  • Assuming missing prop causes error
4. Identify the error in this code snippet:
function Button(props) {
  return {props.label};
}

export default function App() {
  return ;
}
medium
A. Missing quotes around string prop value
B. Incorrect component name
C. Text component cannot display props
D. Props cannot be passed to functional components

Solution

  1. Step 1: Check prop syntax in App component

    The prop label is passed as label=ClickMe without quotes, which is invalid for strings.
  2. Step 2: Understand correct JSX prop passing

    String values must be in quotes like label="ClickMe" or in curly braces if variable.
  3. Final Answer:

    Missing quotes around string prop value -> Option A
  4. Quick Check:

    String props need quotes in JSX [OK]
Hint: Always quote string props in JSX [OK]
Common Mistakes:
  • Forgetting quotes around string props
  • Thinking props can't be passed to functions
  • Misunderstanding Text component usage
5. You want to create a reusable Profile component that shows a user's name and age. Which of these is the best way to pass props to make it flexible?
hard
A.
B.
C.
D.

Solution

  1. Step 1: Check prop value types and syntax

    Strings like name should be in quotes; numbers like age should be passed as JavaScript expressions using curly braces.
  2. Step 2: Evaluate each option

    <Profile name="Alice" age={30} /> correctly passes name as string and age as number. <Profile name={"Alice"} age="30" /> passes age as string which is less ideal. <Profile name=Alice age=30 /> misses quotes and braces. <Profile name={Alice} age={30} /> uses undefined variable Alice.
  3. Final Answer:

    <Profile name="Alice" age={30} /> -> Option B
  4. Quick Check:

    Strings in quotes, numbers in braces [OK]
Hint: Use quotes for strings, braces for numbers in props [OK]
Common Mistakes:
  • Passing numbers as strings
  • Omitting quotes for strings
  • Using undefined variables without quotes
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard