Protect against fatal YellowBox error when stack frame has no file
Summary: Motivation: When viewing a stack trace in YellowBox where one or more of the stack frames has no `file`, JS will encounter the fatal error `null is not an object (evaluating 'file.split')`. This can happen, for example, when running a bundle for which no source maps were generated. Closes https://github.com/facebook/react-native/pull/13512 Differential Revision: D4896480 Pulled By: javache fbshipit-source-id: 202c793a47abb83a4700a5778a92b0b5828b01a3
This commit is contained in:
parent
54d8d10a6b
commit
09e7dbc9cb
|
@ -191,8 +191,13 @@ const StackRow = ({frame}: StackRowProps) => {
|
|||
const Text = require('Text');
|
||||
const TouchableHighlight = require('TouchableHighlight');
|
||||
const {file, lineNumber} = frame;
|
||||
const fileParts = file.split('/');
|
||||
const fileName = fileParts[fileParts.length - 1];
|
||||
let fileName;
|
||||
if (file) {
|
||||
const fileParts = file.split('/');
|
||||
fileName = fileParts[fileParts.length - 1];
|
||||
} else {
|
||||
fileName = '<unknown file>';
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableHighlight
|
||||
|
|
Loading…
Reference in New Issue