hygraph/rich-text

React duplicate key issue

marklundin opened this issue · 3 comments

Running this sandbox with some sample data from GraphCMS flags the following error:

Warning: Encountered two children with the same key, ``. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
    at RenderText (https://i91ddf.csb.app/node_modules/@graphcms/rich-text-react-renderer/dist/rich-text-react-renderer.esm.js:316:23)
    at RenderNode (https://i91ddf.csb.app/node_modules/@graphcms/rich-text-react-renderer/dist/rich-text-react-renderer.esm.js:359:19)
    at RenderElements (https://i91ddf.csb.app/node_modules/@graphcms/rich-text-react-renderer/dist/rich-text-react-renderer.esm.js:445:23)

It looks like this is caused by a '\n' being included in the text content which may be causing additional nodes to be generated that aren't being tracked correctly

Same here. Here is the minimal data causing it for me:

 <RichText
        content={{
          children: [
            {
              type: 'paragraph',
              children: [
                {
                  text: '\n',
                },
              ],
            },
          ],
        }}
      />

Hey @marklundin, thanks a lot for opening this issue!

I'll take a look into it in the following days!

I released 0.4.3 which fixes this issue!