Skip to content

Commit

Permalink
Avoid server insertion react key warning (#51053)
Browse files Browse the repository at this point in the history
Wrap server inseration children with react key to avoid react key
warning display
  • Loading branch information
huozhi committed Jun 9, 2023
1 parent 4080f63 commit 558632b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1458,8 +1458,12 @@ export async function renderToHTMLOrFlight(
ReactDOMServer: require('react-dom/server.edge'),
element: (
<>
{Array.from(serverInsertedHTMLCallbacks).map((callback) =>
callback()
{Array.from(serverInsertedHTMLCallbacks).map(
(callback, index) => (
<React.Fragment key={'_next_insert' + index}>
{callback()}
</React.Fragment>
)
)}
{polyfillsFlushed
? null
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/app-dir/rsc-basic/rsc-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ createNextDescribe(
internalQueries.some((query) => content.includes(query))
)
expect(hasNextInternalQuery).toBe(false)
expect(next.cliOutput).not.toContain(
'Each child in a list should have a unique "key" prop'
)
})

it('should reuse the inline flight response without sending extra requests', async () => {
Expand Down

0 comments on commit 558632b

Please sign in to comment.