Program
function ListItem(props) {
return <li>{props.value}</li&g">
Which of the following code snippets should be there in place of "???" in the below given program so that the following output is printed on the console?
Program
function ListItem(props) {
return <li>{props.value}</li>;
}
function NList(props) {
const numbers = props.numbers;
return (
<ul>
???
</ul>
);
}
const numbers = [8, 6, 4, 2, 1];
ReactDOM.render(
<NList numbers={numbers} />,
document.getElementById('root')
);
Output
• 8
• 6
• 4
• 2
• 1
Correct Answer:
{numbers.map((number) =>
<ListItem key={number.toString()}
value={number} />
)}
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More React.js MCQ Questions