Complete the code to display the prop value inside the component.
function Greeting(props) {
return <h1>Hello, [1]!</h1>;
}In React functional components, props are accessed directly as props.propertyName. Here, props.name correctly accesses the name prop.
Complete the code to pass a prop called 'title' with value 'Welcome' to the Header component.
<Header [1]="Welcome" />
Props are passed as attributes to components. Here, title="Welcome" passes the 'title' prop with the value 'Welcome'.
Fix the error in the code to correctly display the 'age' prop inside the component.
function UserInfo(props) {
return <p>Age: [1]</p>;
}In functional components, props are accessed directly via props.propertyName. Using this.props is for class components only.
Fill both blanks to correctly display the 'firstName' and 'lastName' props inside the component.
function FullName(props) {
return <p>[1] + ' ' + [2]</p>;
}Use props.firstName and props.lastName to access the props inside the component.
Fill all three blanks to create a component that returns a greeting using the 'greeting', 'name', and 'punctuation' props.
function Message(props) {
return <h2>[1] + ', ' + [2] + [3]</h2>;
}Access each prop with props.propName to build the greeting message.