A. Missing curly braces around interpolation expression
B. Incorrect object property access syntax
C. Text component cannot contain variables
D. Missing import for Text component
Solution
Step 1: Check interpolation usage in JSX
In JSX, expressions must be wrapped in curly braces {} to be evaluated.
Step 2: Identify the error
The code uses ${user.firstName} without curly braces, so it will render literally instead of evaluating.
Final Answer:
Missing curly braces around interpolation expression -> Option A
Quick Check:
Use {`...${var}...`} or {var} inside JSX [OK]
Hint: Always wrap interpolations in JSX with curly braces {} [OK]
Common Mistakes:
Using ${} without JSX braces
Trying to access object properties incorrectly
Forgetting to import components
5. You want to display a greeting that changes based on the time of day using interpolation. Which code correctly shows "Good morning" if hour is less than 12, otherwise "Good evening" inside a Text component?