Skip to content

Commit b087322

Browse files
committed
Fast Refresh determines where to source the bundle
1 parent 5ab0292 commit b087322

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

packages/app/windows/Shared/ReactInstance.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,32 +120,36 @@ bool ReactInstance::LoadJSBundleFrom(JSBundleSource source, bool reloadHost)
120120
{
121121
source_ = source;
122122

123-
auto instanceSettings = reactNativeHost_.InstanceSettings();
124123
switch (source) {
125124
case JSBundleSource::DevServer:
126-
instanceSettings.DebugBundlePath(L"index");
125+
// "Fast Refresh" determines whether the bundle is loaded from the
126+
// dev server (since at least 0.76)
127+
// https://github.com/microsoft/react-native-windows/blob/react-native-windows_v0.76.17/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp#L641
128+
UseFastRefresh(true, reloadHost);
127129
break;
128130
case JSBundleSource::Embedded:
129-
auto const bundleRootPath = GetBundleRootPath();
130-
#if USE_FABRIC
131-
instanceSettings.BundleRootPath(L"file://" + bundleRootPath.wstring());
132-
#endif // USE_FABRIC
133-
auto const &bundleName = GetBundleName(bundleRootPath, bundleRoot_);
134-
if (!bundleName.has_value()) {
135-
return false;
136-
}
137-
instanceSettings.JavaScriptBundleFile(bundleName.value());
131+
UseFastRefresh(false, reloadHost);
138132
break;
139133
}
140134

141-
Reload(reloadHost);
142135
return true;
143136
}
144137

145138
void ReactInstance::Reload(bool reloadHost)
146139
{
147140
auto instanceSettings = reactNativeHost_.InstanceSettings();
148141

142+
instanceSettings.DebugBundlePath(L"index");
143+
144+
auto const bundleRootPath = GetBundleRootPath();
145+
#if USE_FABRIC
146+
instanceSettings.BundleRootPath(L"file://" + bundleRootPath.wstring());
147+
#endif // USE_FABRIC
148+
auto const &bundleName = GetBundleName(bundleRootPath, bundleRoot_);
149+
if (bundleName.has_value()) {
150+
instanceSettings.JavaScriptBundleFile(bundleName.value());
151+
}
152+
149153
#if USE_WEB_DEBUGGER
150154
instanceSettings.UseWebDebugger(UseWebDebugger());
151155
#endif // USE_WEB_DEBUGGER
@@ -243,10 +247,10 @@ bool ReactInstance::UseFastRefresh() const
243247
return IsFastRefreshAvailable() && RetrieveLocalSetting(kUseFastRefresh, true);
244248
}
245249

246-
void ReactInstance::UseFastRefresh(bool useFastRefresh)
250+
void ReactInstance::UseFastRefresh(bool useFastRefresh, bool reloadHost)
247251
{
248252
StoreLocalSetting(kUseFastRefresh, useFastRefresh);
249-
Reload();
253+
Reload(reloadHost);
250254
}
251255

252256
bool ReactInstance::UseWebDebugger() const

packages/app/windows/Shared/ReactInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace ReactTestApp
9494
void UseDirectDebugger(bool);
9595

9696
bool UseFastRefresh() const;
97-
void UseFastRefresh(bool);
97+
void UseFastRefresh(bool, bool reloadHost = true);
9898

9999
bool UseWebDebugger() const;
100100
void UseWebDebugger(bool);

0 commit comments

Comments
 (0)