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:
Ben Roth 2017-04-18 09:23:29 -07:00 committed by Facebook Github Bot
parent 54d8d10a6b
commit 09e7dbc9cb
1 changed files with 7 additions and 2 deletions

View File

@ -191,8 +191,13 @@ const StackRow = ({frame}: StackRowProps) => {
const Text = require('Text'); const Text = require('Text');
const TouchableHighlight = require('TouchableHighlight'); const TouchableHighlight = require('TouchableHighlight');
const {file, lineNumber} = frame; const {file, lineNumber} = frame;
const fileParts = file.split('/'); let fileName;
const fileName = fileParts[fileParts.length - 1]; if (file) {
const fileParts = file.split('/');
fileName = fileParts[fileParts.length - 1];
} else {
fileName = '<unknown file>';
}
return ( return (
<TouchableHighlight <TouchableHighlight