react-native
react-native copied to clipboard
Top level bundle errors are not displayed
Description
Overview
If there's an error when evaluating a module, the app crashes and the stack trace is not reported in the console:

Expectation is that the app shows a LogBox with a code frame to the source of the issue, or at least a redbox with the error message and stack trace, and the console includes the stack trace so you can find the source of the problem.
Version
0.70
Output of npx react-native info
Steps to reproduce
- Clone a new app
- Render any component with
propTypes
:
import {ViewPropTypes} from 'react-native';
const MyView = () => {
return <Text>Hello World</Text>;
};
MyView.propTypes = ViewPropTypes;
//...
// In the App.js componet:
<MyView>
Snack, code example, screenshot, or link to a repository
Above
I believe this is fixable with a tweak to react-native
's InitializeCore
module. There are side-effects in AppRegistry
that never run if an error gets thrown very early in user code (at least the way the basic React Native template app is set up), thus preventing React Native from rendering LogBox for the error.
Specifically, by adding the line require('../ReactNative/AppRegistry');
here I was able to get an early error to consistently render a LogBox (with a valid secondary error saying that the app's root component wasn't registered).
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.