Skip to content

Conversation

@spuppo-mux
Copy link
Contributor

@spuppo-mux spuppo-mux commented Nov 18, 2025

Closes #6

The way we create the children array in the SSR case (typeof window === 'undefined') would cause a warning log to appear on NextJS environments. For example: muxinc/next-video#397

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.

This was happening because reactProps.children was being created as an array

reactProps.children = [templateShadowRoot, reactProps.children];

but the templateShadowRoot element didn't have a key. Tried to go for a unique enough key so it wouldn't be repeated, but feel free to suggest changes.

Unrelated to the bug, I also modified the way we pass the children to the createElement function to follow how it's specified in the docs.

I tested this by publishing the package locally using yalc and linking it to @mux/mux-video (and doing the same with this package and next-video and it's example). Then when running the example, you shouldn't see the missing key warning.

Copy link
Collaborator

@luwes luwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@spuppo-mux spuppo-mux merged commit 0de3f05 into muxinc:main Nov 18, 2025
2 checks passed
spuppo-mux added a commit to muxinc/media-chrome that referenced this pull request Nov 27, 2025
Relates to muxinc/next-video#397 and
muxinc/ce-la-react#7

Upgrades ce-la-react to prevent missing key warning when using custom
components on SSR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of children keys results in next.js warning

2 participants