React Arrays & Lists Interview Questions 2026
- Authors

- Name
- Geeks Kai
- @KaiGeeks
Loading share buttons...

This comprehensive guide focuses on React Arrays & Lists interview questions covering dynamic data rendering. Whether you're preparing for your first React.js interview or looking to refresh your knowledge, this resource provides detailed answers with code examples to help you succeed.
What you'll learn:
Perfect for:
Keywords: React Arrays & Lists interview questions, React JS interview questions, React.js interview questions, interview questions on react js Key Features:
In React, lists are usually rendered using JavaScript's .map() method. Each list item should also have a unique key prop so React can efficiently track and update elements.
const fruits = ["Apple", "Banana", "Mango"]
return (
<ul>
{fruits.map((fruit, index) => (
<li key={index}>{fruit}</li>
))}
</ul>
)
In this example, .map() is used to iterate over the array, and the key prop helps React identify each list item uniquely.
key prop important in React lists?The key prop is important because it helps React efficiently manage list rendering. It allows React to identify which items have changed, been added, or removed, instead of re-rendering the entire list.
{
items.map((item) => <ListItem key={item.id} value={item.value} />)
}
Using the array index as keys can lead to performance issues and unexpected behavior, especially when reordering or deleting items. React relies on keys to identify elements uniquely, and using indices can cause components to be re-rendered unnecessarily or display incorrect data.
Problems with index keys:
In React, list items can be conditionally rendered using techniques like if statements, ternary operators, or array methods such as .filter() combined with .map().
const users = [
{ name: "Aman", active: true },
{ name: "Raj", active: false },
]
return (
<ul>
{users
.filter((user) => user.active)
.map((user) => (
<li key={user.name}>{user.name}</li>
))}
</ul>
)
State is immutable, so you cannot modify arrays directly. Instead, you create a new array using methods like .map() or .filter() and then update state with that new array.
Example (removing an item):
const [list, setList] = useState(["A", "B", "C"])
const removeItem = (item) => {
setList(list.filter((i) => i !== item))
}
Example (updating an item):
const updateItem = (id, newValue) => {
setList(list.map((item) => (item.id === id ? { ...item, value: newValue } : item)))
}
In these examples, .filter() and .map() create new arrays without the removed item or with the updated item, and setList updates the state.
Rendering very large lists can hurt performance, so React provides techniques and best practices to optimize them:
react-window or react-virtualized to render only the visible portion of the list.React.memo to prevent unnecessary re-renders.You can nest .map() calls: one for the parent array and another for the child array.
const categories = [
{ name: "Fruits", items: ["Apple", "Banana"] },
{ name: "Veggies", items: ["Carrot", "Tomato"] },
]
return (
<div>
{categories.map((cat) => (
<div key={cat.name}>
<h3>{cat.name}</h3>
<ul>
{cat.items.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
</div>
))}
</div>
)
In this example, each level of data gets its own .map() loop, and both parent and child elements should have unique key props.
In React, since state is immutable, you cannot directly modify the existing array. Instead, you create a new array that includes the new item and update state.
const [list, setList] = useState(["A", "B"])
const addItem = (item) => {
setList([...list, item])
}
In this example:
[...list, item] creates a new array with the existing items plus the new one.setList with this new array updates the state and triggers a re-render, showing the updated list in the UI.In React, lists are usually stored in state, and you can sort or filter them dynamically by creating a new array based on the original list and updating the state.
const [users, setUsers] = useState([
{ name: "Aman", age: 25 },
{ name: "Raj", age: 30 },
{ name: "Sara", age: 22 },
])
// Filter active users
const filteredUsers = users.filter((user) => user.age > 24)
// Sort by name
const sortedUsers = [...users].sort((a, b) => a.name.localeCompare(b.name))
In this example:
filter creates a new array containing only the items that meet the condition.sort rearranges the array items; using [...users] ensures the original state is not mutated.When rendering lists, it's important to return JSX elements for each item. The choice between map() and forEach() affects this:
const fruits = ["Apple", "Banana", "Mango"];
return (
<ul>
{fruits.map(fruit => <li key={fruit}>{fruit}</li>)}
</ul>
);
In this example:
map returns an array of <li> elements, which React renders.forEach here would not work, because it does not return the array of elements.Continue your React JS interview questions preparation with these related topics:
Core React Interview Questions
Master Core React interview questions covering JSX, Virtual DOM, Components, Props, State, and more. Essential React JS ...
React Hooks Interview Questions
Comprehensive React Hooks interview questions covering useState, useEffect, useCallback, useMemo, useReducer, and custom...
React Rendering & Performance Interview Questions
Comprehensive React Rendering & Performance interview questions covering Virtual DOM, memoization, code splitting, and o...
Complete React Interview Guide
Master all aspects of React development
This article is part of our comprehensive React JS interview questions series covering all aspects of React development. Explore all topics: