Skip to content

Commit c2b7fd3

Browse files
committed
[AppRegistry] Avoid using invariant in runApplication to preserve red screen and provide more useful warning
1 parent bbafe25 commit c2b7fd3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Libraries/ReactNative/AppRegistry.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,24 @@ const AppRegistry = {
190190
() => msg,
191191
);
192192
}
193-
invariant(
194-
runnables[appKey] && runnables[appKey].run,
195-
`"${appKey}" has not been registered. This can happen if:\n` +
196-
'* Metro (the local dev server) is run from the wrong folder. ' +
197-
'Check if Metro is running, stop it and restart it in the current project.\n' +
198-
"* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.",
199-
);
193+
194+
// NOTE(brentvatne): the original error message here, commented out below,
195+
// is not useful to developers in the Expo managed workflow. It also will
196+
// prevent any red box error that has occurred while loading the bundle from
197+
// being visible to the user. So, we instead warn and give a more tailored
198+
// message to help users with debugging the issue.
199+
if (!runnables[appKey] || !runnables[appKey].run) {
200+
console.warn(`Unable to start your application. Please refer to https://expo.fyi/no-registered-application for more information.`);
201+
return;
202+
}
203+
204+
// invariant(
205+
// runnables[appKey] && runnables[appKey].run,
206+
// `"${appKey}" has not been registered. This can happen if:\n` +
207+
// '* Metro (the local dev server) is run from the wrong folder. ' +
208+
// 'Check if Metro is running, stop it and restart it in the current project.\n' +
209+
// "* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.",
210+
// );
200211

201212
SceneTracker.setActiveScene({name: appKey});
202213
runnables[appKey].run(appParameters);

0 commit comments

Comments
 (0)