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

Fix junk in React warnings in Logbox #44812

Closed
wants to merge 3 commits into from
Closed
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 @@ -112,6 +112,36 @@ describe('parseLogBoxLog', () => {
});
});

it('does not duplicate message if component stack found but not parsed', () => {
expect(
parseLogBoxLog([
'Warning: Each child in a list should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.%s',
'\n\nCheck the render method of `MyOtherComponent`.',
'',
'\n in\n in\n in',
]),
).toEqual({
componentStackType: 'legacy',
componentStack: [],
category:
'Warning: Each child in a list should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.',
message: {
content:
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `MyOtherComponent`. See https://fb.me/react-warning-keys for more information.',
substitutions: [
{
length: 48,
offset: 62,
},
{
length: 0,
offset: 110,
},
],
},
});
});

it('detects a component stack in an interpolated warning', () => {
expect(
parseLogBoxLog([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export function parseLogBoxLog(args: $ReadOnlyArray<mixed>): {|
}
}

if (componentStack.length === 0) {
if (componentStack.length === 0 && argsWithoutComponentStack.length === 0) {
// Try finding the component stack elsewhere.
for (const arg of args) {
if (typeof arg === 'string' && isComponentStack(arg)) {
Expand Down
Loading