fixing crash on reload JS
This commit is contained in:
parent
afade2530c
commit
bd379dd376
|
@ -9,6 +9,7 @@
|
|||
#include "js_init.h"
|
||||
#include "rpc.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "shared_realm.hpp"
|
||||
#include <unordered_map>
|
||||
#include <android/log.h>
|
||||
|
||||
|
@ -46,6 +47,8 @@ JNIEXPORT jlong JNICALL Java_com_reacttests_RealmReactAndroid_injectRealmJsConte
|
|||
get_jsc_context_t get_jsc_context = (get_jsc_context_t) dlsym(handle, "get_jsc_context");
|
||||
|
||||
if (get_jsc_context != NULL) {
|
||||
// clearing previous instances
|
||||
realm::Realm::s_global_cache.clear();
|
||||
std::unordered_map<JSContextRef, facebook::react::JSCExecutor*> s_globalContextRefToJSCExecutor = get_jsc_context();
|
||||
for (auto pair : s_globalContextRefToJSCExecutor) {
|
||||
RJSInitializeInContext(pair.first);
|
||||
|
@ -93,5 +96,3 @@ JNIEXPORT jlong JNICALL Java_com_reacttests_RealmReactAndroid_injectRealmJsConte
|
|||
env->ReleaseStringUTFChars(chrome_args, args);
|
||||
return env->NewStringUTF(response.dump().c_str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue