Complete the code to display a greeting with the user's name using interpolation.
const Greeting = ({ name }) => {
return <Text>Hello, [1]!</Text>;
};In React Native JSX, to insert a JavaScript variable inside a component, you use curly braces {}. So {name} correctly inserts the variable.
Complete the code to show a message with a variable number using interpolation.
const Message = ({ count }) => {
return <Text>You have [1] new messages.</Text>;
};Use curly braces {count} in JSX to insert the value of the count variable.
Fix the error in the code to correctly interpolate the user's age inside the Text component.
const Age = ({ age }) => {
return <Text>Your age is [1].</Text>;
};In JSX, variables must be wrapped in curly braces to be evaluated. So {age} correctly inserts the variable's value.
Fill both blanks to create a greeting message that includes the user's first and last name using interpolation.
const FullName = ({ firstName, lastName }) => {
return <Text>Hello, [1] [2]!</Text>;
};Use curly braces to insert both firstName and lastName variables inside JSX.
Fill all three blanks to display a message with the user's name and age using interpolation.
const UserInfo = ({ name, age }) => {
return <Text>[1] is [2] years old.</Text>;
};Use curly braces to insert both name and age variables inside JSX text.