mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix component stacks for tsx, ts, and jsx files (#43370)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43370 Component stacks with files ending in .ts, .tsx, or .jsx were skipped in LogBox reporting. This diff fixes the regex. Changelog: [General][Fixed] - Support .tsx, .ts, and .jsx in component stacks Reviewed By: yungsters Differential Revision: D54638526 fbshipit-source-id: a5271daaa7b687e8e075be3f94ab9b9c03f79b66
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2d547a3252
commit
adaf5eba3e
@@ -1287,6 +1287,54 @@ Please follow the instructions at: fburl.com/rn-remote-assets`,
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('detects a component stack for ts, tsx, jsx, and js files', () => {
|
||||||
|
expect(
|
||||||
|
parseLogBoxLog([
|
||||||
|
'Some kind of message\n in MyTSComponent (at MyTSXComponent.ts:1)\n in MyTSXComponent (at MyTSCComponent.tsx:1)\n in MyJSXComponent (at MyJSXComponent.jsx:1)\n in MyJSComponent (at MyJSComponent.js:1)',
|
||||||
|
]),
|
||||||
|
).toEqual({
|
||||||
|
componentStack: [
|
||||||
|
{
|
||||||
|
content: 'MyTSComponent',
|
||||||
|
fileName: 'MyTSXComponent.ts',
|
||||||
|
location: {
|
||||||
|
column: -1,
|
||||||
|
row: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'MyTSXComponent',
|
||||||
|
fileName: 'MyTSCComponent.tsx',
|
||||||
|
location: {
|
||||||
|
column: -1,
|
||||||
|
row: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'MyJSXComponent',
|
||||||
|
fileName: 'MyJSXComponent.jsx',
|
||||||
|
location: {
|
||||||
|
column: -1,
|
||||||
|
row: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'MyJSComponent',
|
||||||
|
fileName: 'MyJSComponent.js',
|
||||||
|
location: {
|
||||||
|
column: -1,
|
||||||
|
row: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
category: 'Some kind of message',
|
||||||
|
message: {
|
||||||
|
content: 'Some kind of message',
|
||||||
|
substitutions: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('detects a component stack in the first argument (JSC)', () => {
|
it('detects a component stack in the first argument (JSC)', () => {
|
||||||
expect(
|
expect(
|
||||||
parseLogBoxLog([
|
parseLogBoxLog([
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ export function parseComponentStack(message: string): ComponentStack {
|
|||||||
if (!s) {
|
if (!s) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const match = s.match(/(.*) \(at (.*\.js):([\d]+)\)/);
|
const match = s.match(/(.*) \(at (.*\.(?:js|jsx|ts|tsx)):([\d]+)\)/);
|
||||||
if (match) {
|
if (match) {
|
||||||
let [content, fileName, row] = match.slice(1);
|
let [content, fileName, row] = match.slice(1);
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user