Unverified Commit 3b592e20 authored by Paweł Tymczuk's avatar Paweł Tymczuk Committed by GitHub

Fix: added the key property to the pre next scripts (#26646)

This fixes the React warning: `Warning: Each child in a list should have a unique "key" prop.` that is thrown when using the `Script` components with the `beforeInteractive` strategy. 

Fixes: #26618 
parent 538095c9
......@@ -76,11 +76,12 @@ function getPreNextScripts(context: DocumentProps, props: OriginProps) {
const { scriptLoader, disableOptimizedLoading } = context
return (scriptLoader.beforeInteractive || []).map(
(file: ScriptLoaderProps) => {
(file: ScriptLoaderProps, index: number) => {
const { strategy, ...scriptProps } = file
return (
<script
{...scriptProps}
key={scriptProps.src || index}
defer={!disableOptimizedLoading}
nonce={props.nonce}
crossOrigin={props.crossOrigin || process.env.__NEXT_CROSS_ORIGIN}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment