Skip to content

Commit 7d7dd3a

Browse files
authored
fix(ReactInstance): Set bridge instance before calling LoadScript (microsoft#745)
JavaScript may call native behaviors prior to the `_bridge` variable being set in `ReactInstance`, which would be invoked in the initial call to `FlushedQueue` following the call to run the bundle. This change set ensures the `_bridge` is set before the bundle is loaded. Fixes microsoft#744
1 parent 3cde737 commit 7d7dd3a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ReactWindows/ReactNative/Bridge/ReactInstance.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,19 @@ public async Task InitializeBridgeAsync()
109109
QueueConfiguration.NativeModulesQueueThread);
110110
}
111111

112+
return bridge;
113+
}).ConfigureAwait(false);
114+
115+
await QueueConfiguration.JavaScriptQueueThread.CallOnQueue(() =>
116+
{
112117
using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "setBatchedBridgeConfig").Start())
113118
{
114-
bridge.SetGlobalVariable("__fbBatchedBridgeConfig", BuildModulesConfig());
119+
_bridge.SetGlobalVariable("__fbBatchedBridgeConfig", BuildModulesConfig());
115120
}
116121

117-
_bundleLoader.LoadScript(bridge);
122+
_bundleLoader.LoadScript(_bridge);
118123

119-
return bridge;
124+
return default(object);
120125
}).ConfigureAwait(false);
121126
}
122127
}

0 commit comments

Comments
 (0)