DomToReact: Allow custom keys for replacement#99
Merged
remarkablemark merged 2 commits intoremarkablemark:masterfrom Mar 29, 2019
Merged
Conversation
remarkablemark
requested changes
Mar 28, 2019
Owner
remarkablemark
left a comment
There was a problem hiding this comment.
Looks good! Just some minor nitpicks if you don't mind updating
test/dom-to-react.js
Outdated
| ); | ||
| }); | ||
|
|
||
| it('does not modify keys for replacement if it have one', () => { |
test/dom-to-react.js
Outdated
| return React.createElement( | ||
| 'custom-button', | ||
| { | ||
| key: 'meyKey', |
test/dom-to-react.js
Outdated
| React.createElement( | ||
| 'custom-button', | ||
| { | ||
| key: 'meyKey', |
remarkablemark
approved these changes
Mar 29, 2019
Owner
|
@NadiaIvaniuckovich Thanks for making the pull request! I'll make a release later tonight. |
Owner
|
html-react-parser@0.6.4 has been published |
d-lazarev
pushed a commit
to d-lazarev/html-react-parser
that referenced
this pull request
Apr 5, 2019
…eact-custom-keys DomToReact: Allow custom keys for replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In current implementation when you use dom-to-react with replace option created elements usually have keys generated from index of node, even if component in replace have it's own key.
According to https://fb.me/react-warning-keys
"We don’t recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state. "
In our case it cause problems with performance.
This pull request will allow using keys from replacement components (for example id of element can be used as key if put it as key to component returned by replace).