diff --git a/android/src/main/java/com/jsiudp/JsiUdpModule.java b/android/src/main/java/com/jsiudp/JsiUdpModule.java index bb54f65..6e5f521 100644 --- a/android/src/main/java/com/jsiudp/JsiUdpModule.java +++ b/android/src/main/java/com/jsiudp/JsiUdpModule.java @@ -12,6 +12,7 @@ @ReactModule(name = JsiUdpModule.NAME) public class JsiUdpModule extends ReactContextBaseJavaModule { public static final String NAME = "JsiUdp"; + private boolean mInstalled = false; public JsiUdpModule(ReactApplicationContext reactContext) { super(reactContext); @@ -30,7 +31,9 @@ public String getName() { @Override public void invalidate() { super.invalidate(); - nativeReset(); + if (mInstalled) { + nativeReset(); + } } @ReactMethod(isBlockingSynchronousMethod = true) @@ -41,6 +44,7 @@ public boolean install() { ReactApplicationContext context = getReactApplicationContext(); CallInvokerHolderImpl holder = (CallInvokerHolderImpl) context.getCatalystInstance().getJSCallInvokerHolder(); nativeInstall(context.getJavaScriptContextHolder().get(), holder); + mInstalled = true; return true; } catch (Exception exception) { return false;