HomeInterview QuestionsHow would you render the list of names in a React …

How would you render the list of names in a React component?

🟢 Easy Coding Junior level
1Times asked
Apr 2026Last seen
Apr 2026First seen

💡 Model Answer

To render the list of names, you map over the names array inside the JSX and return a <li> for each element. Each list item should have a unique key prop to help React identify which items have changed. A typical implementation:

jsx
import React from "react";

const names = ["Ram", "John", "Sara"];

export default function NameList() {
  return (
    <div>
      <h2>Names</h2>
      <ul>
        {names.map((name, index) => (
          <li key={index}>{name}</li>
        ))}
      </ul>
    </div>
  );
}

This component displays a heading and an unordered list of names. Using the array index as the key is acceptable for static lists; for dynamic lists, a unique identifier should be used instead.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500