-
The following code will throw an error saying that there is no unique key for the div. export default function Home() {
const query = useQuery();
return (
<div>
{query.allFilms()?.films?.map((film) => (
<div key={film?.id}>
<p>title: {film?.title}</p>
<p>director: {film?.director}</p>
</div>
))}
</div>
);
} error:
|
Beta Was this translation helpful? Give feedback.
Answered by
vicary
Nov 15, 2024
Replies: 1 comment 1 reply
-
GQty renders a first time with <div>
{query.allFirms()?.films?.map((film) => (
- <div key={film?.id}>
+ <div key={film?.id ?? 0}>
</div>
)}
</div> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
toiroakr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GQty renders a first time with
undefined
to capture your GraphQL selections before fetching, assuming no sane person would use0
as an id you may always to this: