Skip to content

Commit

Permalink
Add reloadWithReason to Fast Refresh
Browse files Browse the repository at this point in the history
Reviewed By: cpojer

Differential Revision: D17499348

fbshipit-source-id: b6e73dc3f396c8531a0872f5572a13928450bb3b
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Sep 30, 2019
1 parent 662b416 commit 61de16b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/metro/src/lib/polyfills/require.js
Expand Up @@ -548,7 +548,7 @@ if (__DEV__) {
if (parentIDs.length === 0) {
// Reload the app because the hot reload can't succeed.
// This should work both on web and React Native.
performFullRefresh();
performFullRefresh('Fast Refresh - No root boundary');
return;
}

Expand Down Expand Up @@ -612,7 +612,7 @@ if (__DEV__) {
const parentIDs = inverseDependencies[updatedID];
if (parentIDs.length === 0) {
// Looks like we bubbled to the root. Can't recover from that.
performFullRefresh();
performFullRefresh('Fast Refresh - Invalidated root boundary');
return;
}
// Schedule all parent refresh boundaries to re-run in this loop.
Expand All @@ -631,7 +631,7 @@ if (__DEV__) {
refreshBoundaryIDs.add(parentID);
updatedModuleIDs.push(parentID);
} else {
performFullRefresh();
performFullRefresh('Fast Refresh - Invalidated boundary');
return;
}
}
Expand Down Expand Up @@ -725,7 +725,7 @@ if (__DEV__) {
return false;
};

const performFullRefresh = () => {
const performFullRefresh = (reason: string) => {
/* global window */
if (
typeof window !== 'undefined' &&
Expand All @@ -737,7 +737,7 @@ if (__DEV__) {
// This is attached in setUpDeveloperTools.
const {Refresh} = metroRequire;
if (Refresh != null) {
Refresh.performFullRefresh();
Refresh.performFullRefresh(reason);
} else {
console.warn('Could not reload the application after an edit.');
}
Expand Down

0 comments on commit 61de16b

Please sign in to comment.