In accordance with the reaction documentation
To expose a JavaScript method, the Java method must be annotated using @ReactMethod. The return type of bridge methods is always invalid. React Native bridge is asynchronous, so the only way to pass JavaScript results is to use callbacks or emit events
So, if you want to return some value, like boolean or string, you need to use callbacks.
Example:
@ReactMethod public void isEqual( int a, int b, Callback booleanCallback) { boolean equal= a == b; booleanCallback.invoke(equal); }
In a javascript call as shown below ...
YourClass.isEqual( 5, 10, (status) => { console.log('Result ',status); } );
For more information see this
Jickson
source share