Skip to content

Commit

Permalink
Fix server key warning (#4973)
Browse files Browse the repository at this point in the history
The current canary version shows the following warning in development mode:

```log
Warning: Each child in an array or iterator should have a unique "key" prop. See https://fb.me/react-warning-keys for more information.
    in script
    in NextScript
    in body
    in html
    in Document
```

This PR adds proper keys to the devFiles on the server.

Related #4954
  • Loading branch information
HaNdTriX authored and timneutkens committed Aug 17, 2018
1 parent 25de2e8 commit 0acba73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/document.js
Expand Up @@ -204,7 +204,7 @@ export class NextScript extends Component {
const pagePathname = getPagePathname(pathname)

return <Fragment>
{devFiles ? devFiles.map((file) => <script src={`${assetPrefix}/_next/${file}`} nonce={this.props.nonce} />) : null}
{devFiles ? devFiles.map((file) => <script key={file} src={`${assetPrefix}/_next/${file}`} nonce={this.props.nonce} />) : null}
{staticMarkup ? null : <script nonce={this.props.nonce} dangerouslySetInnerHTML={{
__html: NextScript.getInlineScriptSource(this.context._documentProps)
}} />}
Expand Down

0 comments on commit 0acba73

Please sign in to comment.