-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate children keys in getStylesheetPrefetchLinks
#5677
Comments
I imagine doing something like the code below in remix-react/links.ts would resolve the issue, but I'm not totally sure if that wouldn't break anything. diff --git a/packages/remix-react/links.ts b/packages/remix-react/links.ts
index 6c070d574..dc59eb38e 100644
--- a/packages/remix-react/links.ts
+++ b/packages/remix-react/links.ts
@@ -338,6 +338,15 @@ export async function getStylesheetPrefetchLinks(
.flat(1)
.filter(isHtmlLinkDescriptor)
.filter((link) => link.rel === "stylesheet" || link.rel === "preload")
+ .filter(
+ // Dedupe links by rel and href
+ (link, indexToFind, linksArr) => {
+ let foundIndex = linksArr.findIndex(needle => {
+ return needle.href === link.href && needle.rel === link.rel;
+ });
+ return foundIndex === indexToFind
+ }
+ )
.map((link) =>
link.rel === "preload"
? ({ ...link, rel: "prefetch" } as HtmlLinkDescriptor)
|
Thanks for raising this issue, and thanks for the suggested fix! I've opened a PR that goes a bit further than your suggested fix because this was actually a symptom of a deeper issue: #7060 |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
What version of Remix are you using?
1.14.0
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
/build/_assets/Component-O4OLHRZ6.css
. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version." warning in the devtools console.The issue is that we're importing the stylesheet in a component, that is imported in a few different places.
Expected Behavior
No errors in the console.
Actual Behavior
There's an error in the devtools console "Warning: Encountered two children with the same key,
/build/_assets/Component-O4OLHRZ6.css
. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version."The text was updated successfully, but these errors were encountered: