Why can't I use my card parameter in React component with PortableText?

61 repliesLast updated: Nov 29, 2025

hi, i dont understand why i cant use my card parameter in my react component
{cards.map((card, index) => {
        return <Card position={{ top: "top-[200px]", left: "left-0" }}>
          <PortableText
            value={data[0].card}
            components={portraitPortableTextComponents}
          />
        </Card>
      })}
AI Update

The issue is that you're not using the card parameter from your .map() function - you're referencing data[0].card instead, which means you're always rendering the same card content for every item in your array.

Here's the fix:

{cards.map((card, index) => {
  return (
    <Card position={{ top: "top-[200px]", left: "left-0" }}>
      <PortableText
        value={card}  // Use the 'card' from map, not data[0].card
        components={portraitPortableTextComponents}
      />
    </Card>
  )
})}

What was wrong:

Additional tips:

If you're still having issues, check the console for any errors and verify what cards actually contains by logging it: console.log(cards).

Show original thread
61 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions