KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
⚛️

React

Topic Hub & Articles

React Intro

10 min

Recap Quiz

Gated

Milestone Assessment

React Getting Started

10 min

React ES6

10 min

React Render HTML

10 min

Recap Quiz

Gated

Milestone Assessment

React JSX

10 min

React Components

10 min

React Class Components

10 min

Recap Quiz

Gated

Milestone Assessment

React Props

10 min

React Events

10 min

React Conditionals

10 min

Recap Quiz

Gated

Milestone Assessment

React Lists

10 min

React Forms

10 min

React Router

10 min

Recap Quiz

Gated

Milestone Assessment

React Memo

10 min

React CSS Styling

10 min

React Sass Styling

10 min

Recap Quiz

Gated

Milestone Assessment

React Fragments

10 min

React Portals

10 min

React Profiler

10 min

Recap Quiz

Gated

Milestone Assessment

React Strict Mode

10 min

React Higher Order Components

10 min

React Context API

10 min

React Error Boundaries

10 min

What is a Hook

10 min

Recap Quiz

Gated

Milestone Assessment

useState

10 min

useEffect

10 min

useContext

10 min

Recap Quiz

Gated

Milestone Assessment

useRef

10 min

useReducer

10 min

useCallback

10 min

Recap Quiz

Gated

Milestone Assessment

useMemo

10 min

Custom Hooks

10 min

useLayoutEffect

10 min

Recap Quiz

Gated

Milestone Assessment

useImperativeHandle

10 min

useDebugValue

10 min

useDeferredValue

10 min

Recap Quiz

Gated

Milestone Assessment

useTransition

10 min

useId

10 min

Progress
0%

0 / 38 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
ReactReact Tutorial
Lesson

React Lists

10 min reading
Free Course

React Lists: Rendering Dynamic Data with Stable Keys

Applications display lists everywhere—from navigation links and notification feeds to shopping cart rows. In React, you transform arrays of data into arrays of JSX elements using JavaScript's .map() method, paired with a unique key prop on each returned item.

Why the key Prop Matters

React uses key strings to match items across renders when rows are added, reordered, or deleted. Without stable keys, React cannot tell which row moved, so it may update the wrong DOM node or mix up input values between items.

export function InvoiceList({ invoices, onSelect }) {
  if (invoices.length === 0) {
    return <p>No invoices found.</p>;
  }

  return (
    <ul className="invoice-list">
      {invoices.map((invoice) => (
        <li key={invoice.id} className="invoice-item">
          <span>#{invoice.number} — ${invoice.total}</span>
          <button type="button" onClick={() => onSelect(invoice.id)}>
            View
          </button>
        </li>
      ))}
    </ul>
  );
}

Picking the Right Key Source

  • Database or API IDs: Best choice (key={user.id}, key={post.slug}) because IDs remain fixed even if the array is sorted or filtered.
  • Array Index (key={index}): Safe only when the list is static, never reordered, never filtered, and contains no stateful inputs.
  • Random Values (Math.random() or crypto.randomUUID() during render): Never generate keys inside .map(). A fresh key on every render forces React to destroy and rebuild every row from scratch.

Common List Rendering Mistakes

  • Putting key on the Inner Element Instead of the Root: When .map() returns <ListItem key={item.id} />, put key directly on <ListItem>, not on the <li> inside ListItem.
  • Duplicate Keys: Two sibling items sharing the same key trigger React console warnings and cause missing or duplicated rows during updates.

Frequently Asked Questions

Can I read props.key inside a child component?

No. React strips key internally and does not pass it down as a prop. Pass a separate prop such as itemId={item.id} if the child needs the identifier.

How do I return two sibling elements per list item?

Use the explicit <Fragment key={item.id}>...</Fragment> syntax, since the shorthand <>...</> cannot accept a key prop.

Should keys be globally unique across the entire app?

No. Keys only need to be unique among sibling elements inside the same array.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

React Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format JSX/HTML markup
CSS Formatter
Clean and format stylesheets
All React Articles
Deep-dive guides, tips & discussions
PreviousReact Conditionals
Continue JourneyNext: React Forms

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum