Skip to content

Commit

Permalink
Try the new thing
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Mar 13, 2020
1 parent aca9c8a commit ea3cccd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 68 deletions.
25 changes: 25 additions & 0 deletions packages/react/src/__tests__/ReactElementJSX-test.js
Expand Up @@ -351,6 +351,31 @@ describe('ReactElement.jsx', () => {
);
});

if (require('shared/ReactFeatureFlags').warnAboutSpreadingKeyToJSX) {
it('should warn when keys are passed as part of props', () => {
const container = document.createElement('div');
class Child extends React.Component {
render() {
return React.jsx('div', {});
}
}
class Parent extends React.Component {
render() {
return React.jsx('div', {
children: [React.jsx(Child, {key: '0'})],
});
}
}
expect(() =>
ReactDOM.render(React.jsx(Parent, {}), container),
).toErrorDev(
'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. <Child {...props} key={key} />',
);
});
}

it('should not warn when unkeyed children are passed to jsxs', () => {
const container = document.createElement('div');
class Child extends React.Component {
Expand Down

This file was deleted.

0 comments on commit ea3cccd

Please sign in to comment.