function Greeting({ name }) { return <h1>Hello, {name}!</h1>; } // Usage <Greeting name="Alice" />
The component receives a prop called name and uses it inside the JSX to display the greeting. Since name is passed as "Alice", the output is "Hello, Alice!".
count?function Parent() { const count = 5; return <Child count={count} />; } function Child({ count }) { return <p>{count}</p>; }
The Parent component passes the number 5 as the count prop to Child. So Child receives count = 5.
title and subtitle, to a component. Which option is syntactically correct in React?In JSX, props are passed as attributes separated by spaces without commas or semicolons. Option A and D look similar, but D is also valid JSX. Both A and D are valid syntax for passing multiple props.
Child component not display the passed prop message?function Parent() { const message = "Hi!"; return <Child msg={message} />; } function Child({ message }) { return <p>{message}</p>; }
The Parent passes a prop named msg, but Child expects a prop named message. Because the names differ, message is undefined in Child.
function Display({ text }) { return <p>{text}</p>; } // Usage <Display />
If a prop is missing, its value is undefined. Rendering {undefined} in JSX results in no visible text, but the element still exists. So the paragraph renders but appears empty or shows "undefined" if coerced to string.