Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify wording of key warning #14503

Merged
merged 1 commit into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe('ReactFunctionComponent', () => {
}

expect(() => ReactTestUtils.renderIntoDocument(<Child />)).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.\n\n' +
'Each child in a list should have a unique "key" prop.\n\n' +
'Check the render method of `Child`.',
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactMultiChildText-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ describe('ReactMultiChildText', () => {
['', 'foo', <div>{true}{<div />}{1.2}{''}</div>, 'foo'], ['', 'foo', <div />, 'foo'],
]);
}).toWarnDev([
'Warning: Each child in an array or iterator should have a unique "key" prop.',
'Warning: Each child in an array or iterator should have a unique "key" prop.',
'Warning: Each child in a list should have a unique "key" prop.',
'Warning: Each child in a list should have a unique "key" prop.',
]);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if (__DEV__) {
child._store.validated = true;

const currentComponentErrorInfo =
'Each child in an array or iterator should have a unique ' +
'Each child in a list should have a unique ' +
'"key" prop. See https://fb.me/react-warning-keys for ' +
'more information.' +
getCurrentFiberStackInDev();
Expand All @@ -91,7 +91,7 @@ if (__DEV__) {

warning(
false,
'Each child in an array or iterator should have a unique ' +
'Each child in a list should have a unique ' +
'"key" prop. See https://fb.me/react-warning-keys for ' +
'more information.',
);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/__tests__/ReactFragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ describe('ReactFragment', () => {

ReactNoop.render(<Foo condition={false} />);
expect(ReactNoop.flush).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
'Each child in a list should have a unique "key" prop.',
);

expect(ops).toEqual([]);
Expand Down Expand Up @@ -753,20 +753,20 @@ describe('ReactFragment', () => {

ReactNoop.render(<Foo condition={true} />);
expect(ReactNoop.flush).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
'Each child in a list should have a unique "key" prop.',
);

ReactNoop.render(<Foo condition={false} />);
expect(ReactNoop.flush).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
'Each child in a list should have a unique "key" prop.',
);

expect(ops).toEqual(['Update Stateful']);
expect(ReactNoop.getChildren()).toEqual([span(), div()]);

ReactNoop.render(<Foo condition={true} />);
expect(ReactNoop.flush).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
'Each child in a list should have a unique "key" prop.',
);

expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function validateExplicitKey(element, parentType) {
if (__DEV__) {
warning(
false,
'Each child in an array or iterator should have a unique "key" prop.' +
'Each child in a list should have a unique "key" prop.' +
'%s%s See https://fb.me/react-warning-keys for more information.',
currentComponentErrorInfo,
childOwner,
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/__tests__/ReactChildren-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('ReactChildren', () => {

let instance;
expect(() => (instance = <div>{threeDivIterable}</div>)).toWarnDev(
'Warning: Each child in an array or iterator should have a unique "key" prop.',
'Warning: Each child in a list should have a unique "key" prop.',
);

function assertCalls() {
Expand Down Expand Up @@ -905,7 +905,7 @@ describe('ReactChildren', () => {
ReactTestUtils.renderIntoDocument(<ComponentReturningArray />),
).toWarnDev(
'Warning: ' +
'Each child in an array or iterator should have a unique "key" prop.' +
'Each child in a list should have a unique "key" prop.' +
' See https://fb.me/react-warning-keys for more information.' +
'\n in ComponentReturningArray (at **)',
);
Expand All @@ -926,7 +926,7 @@ describe('ReactChildren', () => {
ReactTestUtils.renderIntoDocument([<div />, <div />]),
).toWarnDev(
'Warning: ' +
'Each child in an array or iterator should have a unique "key" prop.' +
'Each child in a list should have a unique "key" prop.' +
' See https://fb.me/react-warning-keys for more information.',
{withoutStack: true}, // There's nothing on the stack
);
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/__tests__/ReactElementClone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ describe('ReactElementClone', () => {
it('warns for keys for arrays of elements in rest args', () => {
expect(() =>
React.cloneElement(<div />, null, [<div />, <div />]),
).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
);
).toWarnDev('Each child in a list should have a unique "key" prop.');
});

it('does not warns for arrays of elements with keys', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ describe('ReactElementValidator', () => {

expect(() => {
Component(null, [Component(), Component()]);
}).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
);
}).toWarnDev('Each child in a list should have a unique "key" prop.');
});

it('warns for keys for arrays of elements with owner info', () => {
Expand All @@ -67,7 +65,7 @@ describe('ReactElementValidator', () => {
expect(() => {
ReactTestUtils.renderIntoDocument(React.createElement(ComponentWrapper));
}).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.' +
'Each child in a list should have a unique "key" prop.' +
'\n\nCheck the render method of `InnerClass`. ' +
'It was passed a child from ComponentWrapper. ',
);
Expand All @@ -84,7 +82,7 @@ describe('ReactElementValidator', () => {
expect(() => {
ReactTestUtils.renderIntoDocument(<Anonymous>{divs}</Anonymous>);
}).toWarnDev(
'Warning: Each child in an array or iterator should have a unique ' +
'Warning: Each child in a list should have a unique ' +
'"key" prop. See https://fb.me/react-warning-keys for more information.\n' +
' in div (at **)',
);
Expand All @@ -96,7 +94,7 @@ describe('ReactElementValidator', () => {
expect(() => {
ReactTestUtils.renderIntoDocument(<div>{divs}</div>);
}).toWarnDev(
'Warning: Each child in an array or iterator should have a unique ' +
'Warning: Each child in a list should have a unique ' +
'"key" prop.\n\nCheck the top-level render call using <div>. See ' +
'https://fb.me/react-warning-keys for more information.\n' +
' in div (at **)',
Expand All @@ -117,7 +115,7 @@ describe('ReactElementValidator', () => {
}

expect(() => ReactTestUtils.renderIntoDocument(<GrandParent />)).toWarnDev(
'Warning: Each child in an array or iterator should have a unique ' +
'Warning: Each child in a list should have a unique ' +
'"key" prop.\n\nCheck the render method of `Component`. See ' +
'https://fb.me/react-warning-keys for more information.\n' +
' in div (at **)\n' +
Expand Down Expand Up @@ -161,7 +159,7 @@ describe('ReactElementValidator', () => {
};

expect(() => Component(null, iterable)).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
'Each child in a list should have a unique "key" prop.',
);
});

Expand Down
10 changes: 3 additions & 7 deletions packages/react/src/__tests__/ReactJSXElementValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ describe('ReactJSXElementValidator', () => {
ReactTestUtils.renderIntoDocument(
<Component>{[<Component />, <Component />]}</Component>,
),
).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
);
).toWarnDev('Each child in a list should have a unique "key" prop.');
});

it('warns for keys for arrays of elements with owner info', () => {
Expand All @@ -69,7 +67,7 @@ describe('ReactJSXElementValidator', () => {
expect(() =>
ReactTestUtils.renderIntoDocument(<ComponentWrapper />),
).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.' +
'Each child in a list should have a unique "key" prop.' +
'\n\nCheck the render method of `InnerComponent`. ' +
'It was passed a child from ComponentWrapper. ',
);
Expand All @@ -90,9 +88,7 @@ describe('ReactJSXElementValidator', () => {

expect(() =>
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>),
).toWarnDev(
'Each child in an array or iterator should have a unique "key" prop.',
);
).toWarnDev('Each child in a list should have a unique "key" prop.');
});

it('does not warn for arrays of elements with keys', () => {
Expand Down