-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
I stumble upon the following warning when i use the next-video component as intended.
Check the render method of `i`. See https://react.dev/link/warning-keys for more information.
Each child in a list should have a unique "key" prop.
I used Cursor to dive into the next-video codebase so it could find the specific bug causing this warning. I therefore added a bug report here, but was to lazy to write it myself, so i got cursor to do it 😆
Bug Report
React warning: "Each child in a list should have a unique key" when using NextVideo component.
Affected Versions
- 2.3.0
- 2.5.0
Location
dist/components/video.js lines 44-85
Problem
The component renders children in an array without keys:
return /* @__PURE__ */ jsxs("div", { className: `${className ? `${className} ` : ""}next-video-container`, style, children: [
/* @__PURE__ */ jsx("style", { ... }), // No key
/* @__PURE__ */ jsx(VideoPlayer, { ... }), // No key
DEV_MODE && /* @__PURE__ */ jsx(Alert, { ... }) // Conditional, no key
] });Steps to Reproduce
- Use NextVideo component in development mode
- Open browser console
- See warning: "Each child in a list should have a unique 'key' prop"
Expected Behavior
No React warning in console.
Suggested Fix
Add keys to the children:
return /* @__PURE__ */ jsxs("div", { className: `${className ? `${className} ` : ""}next-video-container`, style, children: [
/* @__PURE__ */ jsx("style", { key: "style", ... }),
/* @__PURE__ */ jsx(VideoPlayer, { key: "player", ... }),
DEV_MODE && /* @__PURE__ */ jsx(Alert, { key: "alert", ... })
] });Metadata
Metadata
Assignees
Labels
No labels