Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Conversation

@ffugly
Copy link

@ffugly ffugly commented Mar 24, 2018

I find this library useful for rendering DraftJS blocks. However, in the event that I have a view component that renders more than one chunk of DraftJS content with renderHTML, I get a duplicate key warning from React.

For example, with a JSX view component that looks something like this:

<h2>About this property</h2>
{renderHTML(draftPropertyDescription)}  // - <p>OMG, the property is amazing...</p>
<h2>About the owner</h2>
{renderHTML(draftOwnerBio)} // - <p>OMG, the owner is so cool </p>

I would get a duplicate key error from the output:

<h2>About this property</h2>
<p key="0">OMG, the property is amazing...</p>
<h2>About the owner</h2>
<p key="0">OMG, the owner is so cool</p>

This pull request would simply append a random hex string to the key value so the output would end up like so:

<h2>About this property</h2>
<p key="0-8ead91">OMG, the property is amazing...</p>
<h2>About the owner</h2>
<p key="0-f5888e">OMG, the owner is cool</p>

Result is no more duplicate key errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant