From 08baec61c211f30546fda44a2a0b126e54f96e33 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 27 Jun 2019 14:08:44 -0700 Subject: [PATCH] Re-evaluate parent modules when refresh boundary updates are incompatible Summary: This is a revamp of how we decide whether to stop at a refresh boundary or to bubble to the next one. We used to decide that at module initialization. However, that's both unnecessary overhead on start (for modules you don't plan to edit), and is actually insufficient. In particular, even if a module only exports components (and thus is a Refresh Boundary), consecutive versions of that module might not be compatible. For example, any of these changes should trigger reevaluation of parents: - Adding or removing exports - Renaming the exported component (which probably means you exported a different one, and we shouldn't preserve state) - Converting from a class to a function, or back - Wrapping something in a HOC The new system handles these cases by comparing the Refresh "families" corresponding to exports, and bubbling the update up if some of them don't match up. The tests have been rewritten from the webpack-inspired `module.hot` API (which we no longer use directly) to the Refresh API. Reviewed By: rubennorte Differential Revision: D16036044 fbshipit-source-id: 18018548d4aaa05877ae6fbaffe40c993c77cdf0 --- Libraries/Core/setUpReactRefresh.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/Core/setUpReactRefresh.js b/Libraries/Core/setUpReactRefresh.js index ffd698c50ab..b723c5c1414 100644 --- a/Libraries/Core/setUpReactRefresh.js +++ b/Libraries/Core/setUpReactRefresh.js @@ -36,6 +36,8 @@ if (__DEV__) { isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType, + getFamilyByType: ReactRefreshRuntime.getFamilyByType, + register: ReactRefreshRuntime.register, performReactRefresh() {