mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-14 09:59:12 +08:00
Enable CodePush for react-native-windows v0.50+ (#1051)
In react-native-windows v0.50+, we added ReactNativeHost, which has better support for running React Native in the background as well as embedding React Native in other controls besides XAML Pages.
This commit is contained in:
committed by
Sergey Akhalkov
parent
cccdc1c2de
commit
cf36d1cf25
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#if WINDOWS_UWP
|
||||
using Windows.Web.Http;
|
||||
@@ -312,17 +313,7 @@ namespace CodePush.ReactNative
|
||||
{
|
||||
// #1) Get the private ReactInstanceManager, which is what includes
|
||||
// the logic to reload the current React context.
|
||||
FieldInfo info = typeof(ReactPage)
|
||||
.GetField("_reactInstanceManager", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
#if WINDOWS_UWP
|
||||
var reactInstanceManager = (ReactInstanceManager)typeof(ReactPage)
|
||||
.GetField("_reactInstanceManager", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
.GetValue(_codePush.MainPage);
|
||||
#else
|
||||
var reactInstanceManager = ((Lazy<IReactInstanceManager>)typeof(ReactPage)
|
||||
.GetField("_reactInstanceManager", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
.GetValue(_codePush.MainPage)).Value as ReactInstanceManager;
|
||||
#endif
|
||||
var reactInstanceManager = _codePush.ReactInstanceManager;
|
||||
|
||||
// #2) Update the locally stored JS bundle file path
|
||||
Type reactInstanceManagerType = typeof(ReactInstanceManager);
|
||||
@@ -332,7 +323,7 @@ namespace CodePush.ReactNative
|
||||
.SetValue(reactInstanceManager, latestJSBundleFile);
|
||||
|
||||
// #3) Get the context creation method and fire it on the UI thread (which RN enforces)
|
||||
Context.RunOnDispatcherQueueThread(reactInstanceManager.RecreateReactContextInBackground);
|
||||
Context.RunOnDispatcherQueueThread(() => reactInstanceManager.RecreateReactContextAsync(CancellationToken.None));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user