OneGraph / graphiql-explorer

Explorer plugin for GraphiQL
MIT License
904 stars 97 forks source link

Add key to fix unique key error #53

Closed oney closed 3 years ago

oney commented 4 years ago

I got Warning: Each child in an array or iterator should have a unique "key" prop error on React 16.13.1. This PR fixes the problem.

If someone wants a quick fix, use https://github.com/ds300/patch-package and apply the below patch.

graphiql-explorer+0.6.2.patch

diff --git a/node_modules/graphiql-explorer/dist/Explorer.js b/node_modules/graphiql-explorer/dist/Explorer.js
index 5c8ce51..579f418 100644
--- a/node_modules/graphiql-explorer/dist/Explorer.js
+++ b/node_modules/graphiql-explorer/dist/Explorer.js
@@ -2475,6 +2475,7 @@ var Explorer = function (_React$PureComponent9) {
             };

             return React.createElement(RootView, {
+              key: index,
               isLast: index === relevantOperations.length - 1,
               fields: fields,
               operationType: operationType,