Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Fix React warnings (#2221)
Browse files Browse the repository at this point in the history
Summary:
**Summary**

Fix instances of the React warning:
```
React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
        'Explicitly pass a key after spreading props in your JSX call. ' +
        'E.g. <ComponentName {...props} key={key} />'
```
originating from [React here](https://github.com/facebook/react/blob/18d2e0c03e4496a824fdb7f89ea2a3d60c30d49a/packages/react/src/ReactElementValidator.js#L366-L373)

This warning occurs when you spread a key with other props. There are probably more instances of this issue but these are the highest firing in our codebase.

**Test Plan**

`npm run lint && npm run test`
Pull Request resolved: #2221

Reviewed By: mitermayer

Differential Revision: D18038272

Pulled By: steveluscher

fbshipit-source-id: 736236601ace92ae1e8d127e10bb35e393fa14b7
  • Loading branch information
Alan Norbauer authored and facebook-github-bot committed Oct 21, 2019
1 parent 42a9d8b commit 2595016
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
customStyleFn,
editorKey: this._editorKey,
editorState,
key: 'contents' + this.state.contentsKey,
textDirectionality,
};

Expand Down Expand Up @@ -420,7 +419,10 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
all DraftEditorLeaf nodes so it's first in postorder traversal.
*/}
<UpdateDraftEditorFlags editor={this} editorState={editorState} />
<DraftEditorContents {...editorContentsProps} />
<DraftEditorContents
{...editorContentsProps}
key={'contents' + this.state.contentsKey}
/>
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/component/contents/DraftEditorContents-core.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class DraftEditorContents extends React.Component<Props> {
decorator,
direction,
forceSelection,
key,
offsetKey,
selection,
tree: editorState.getBlockTree(key),
Expand Down Expand Up @@ -225,7 +224,7 @@ class DraftEditorContents extends React.Component<Props> {
const child = React.createElement(
Element,
childProps,
<Component {...componentProps} />,
<Component {...componentProps} key={key} />,
);

processedBlocks.push({
Expand Down

0 comments on commit 2595016

Please sign in to comment.