Skip to content

Commit

Permalink
[AppRegistry] Avoid using invariant in runApplication to preserve red…
Browse files Browse the repository at this point in the history
… screen and provide more useful warning
  • Loading branch information
brentvatne committed Jul 7, 2020
1 parent bbafe25 commit c2b7fd3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Libraries/ReactNative/AppRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,24 @@ const AppRegistry = {
() => msg,
);
}
invariant(
runnables[appKey] && runnables[appKey].run,
`"${appKey}" has not been registered. This can happen if:\n` +
'* Metro (the local dev server) is run from the wrong folder. ' +
'Check if Metro is running, stop it and restart it in the current project.\n' +
"* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.",
);

// NOTE(brentvatne): the original error message here, commented out below,
// is not useful to developers in the Expo managed workflow. It also will
// prevent any red box error that has occurred while loading the bundle from
// being visible to the user. So, we instead warn and give a more tailored
// message to help users with debugging the issue.
if (!runnables[appKey] || !runnables[appKey].run) {
console.warn(`Unable to start your application. Please refer to https://expo.fyi/no-registered-application for more information.`);
return;
}

// invariant(
// runnables[appKey] && runnables[appKey].run,
// `"${appKey}" has not been registered. This can happen if:\n` +
// '* Metro (the local dev server) is run from the wrong folder. ' +
// 'Check if Metro is running, stop it and restart it in the current project.\n' +
// "* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.",
// );

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

0 comments on commit c2b7fd3

Please sign in to comment.