Fixing error on first mount should fall back to reload

Summary:
This updates `react-refresh` to 0.3.0 which brings a new feature: we can now detect if the root fails on _the initial mount_. In that case we currently can't recover with Fast Refresh because we don't know which element to retry mounting. (In the future, we can lift this limitation, but it would require more changes in React renderer.)

Before this diff, after you fix an error on initial mount, you would see a blank screen (because nothing managed to mount).

After this diff, after you fix an error on initial mount, you would fall back to a full reload.

This diff doesn't affect errors on updates. We can recover from those, just like before.

Reviewed By: cpojer

Differential Revision: D16440836

fbshipit-source-id: 4a414202a9eab894acd7baa0525c25ff003dd323
This commit is contained in:
Dan Abramov 2019-07-23 16:15:20 -07:00 коммит произвёл Facebook Github Bot
Родитель 05d3e86244
Коммит 8b5ed7abdd
3 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -35,7 +35,13 @@ if (__DEV__) {
register: ReactRefreshRuntime.register,
performReactRefresh: ReactRefreshRuntime.performReactRefresh,
performReactRefresh() {
if (ReactRefreshRuntime.hasUnrecoverableErrors()) {
NativeDevSettings.reload();
return;
}
ReactRefreshRuntime.performReactRefresh();
},
};
(require: any).Refresh = Refresh;

Просмотреть файл

@ -104,7 +104,7 @@
"promise": "^7.1.1",
"prop-types": "^15.7.2",
"react-devtools-core": "^3.6.2",
"react-refresh": "^0.2.0",
"react-refresh": "^0.3.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "0.14.0",
"stacktrace-parser": "^0.1.3",

Просмотреть файл

@ -5926,10 +5926,10 @@ react-proxy@^1.1.7:
lodash "^4.6.1"
react-deep-force-update "^1.0.0"
react-refresh@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.2.0.tgz#f0cff375e8f75dea7133a847a1b40cf5c073dd0d"
integrity sha512-ITw8t/HOFNose2yf1y9pPFSSeB9ISOq2JdHpuZvj/Qb+iSsLml8GkkHdDlURzieO7B3dFDtMrrneZLl3N5z/hg==
react-refresh@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.3.0.tgz#dcbf3c1f2fd2f06dc553c4682cf4ae8e72413b05"
integrity sha512-Q4VkuukL/FMo01lifODwMPl6/Pa1OUDJqBEHNw8aLnWIoNsX2BmzRUG+5V7bAPLRXw/fWHNFOmcwRqFfGKrpBw==
react-test-renderer@16.8.6:
version "16.8.6"