I'm developing a native module for Android in React Native. I have two method with the same name but I can't use them in React Native because Java Script has not overloading directly. So I write a function which can get null as a paramater in React Native and try to handle it in Java.
React Native side:
function a(arg=null){
moduleName.b(arg)
}
Java side:
public void b(@Nullable Boolean arg, final Promise promise){
if(arg == null){
c()
}else{
c(arg)
}
}
Then I have not problem when I pass true or false to function a but when I pass nothing to funtion a I get an error on my phone like that:
What is the problem?
This can be due to multiple things going wrong into code. Some areas which needs to look are:
boolean instead of Boolean in your Java code.getIntent() function is not returning null intent , just before receiving intent from bundle.Boolean with null , that's why it's throwing java.lang.Boolean on a null object reference.