Skip to content

Commit

Permalink
fix: crash on reload before library installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Jun 6, 2023
1 parent 34d75fb commit 9532b4d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion android/src/main/java/com/jsiudp/JsiUdpModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,7 +31,9 @@ public String getName() {
@Override
public void invalidate() {
super.invalidate();
nativeReset();
if (mInstalled) {
nativeReset();
}
}

@ReactMethod(isBlockingSynchronousMethod = true)
Expand All @@ -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;
Expand Down

0 comments on commit 9532b4d

Please sign in to comment.