Deduplicate External Scripts #226
Closed
AndrewLeedham
started this conversation in
Ideas
Replies: 1 comment
-
Since 7.0.1 ExternalScripts dedupe scripts using the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If multiple matching routes include the same script you get a
Encountered two children with the same key
warning from react because it is trying to include both and using the same script src as the key. I can't think of a use case off hand where you would want the same script twice, so deduplicating the scripts seems logical to me? If there is a use-case, it could be opt-in.Thinking something like
.filter((value, index, array) => !array.slice(0, index).find((props) => props?.src === value?.src))
here (probably much more efficient ways of doing this, but I doubt there will be many items to compare here): https://github.com/sergiodxa/remix-utils/blob/a2324ace94a2b209f33669cbb3518a9d6cf78780/src/react/external-scripts.tsx#L49C6-L49C6Beta Was this translation helpful? Give feedback.
All reactions