How it works...
This recipe covers the foundation for much of what we'll be doing with adding native Android modules in future recipes. All native module classes need to extend ReactContextBaseJavaModule, implement the constructor, and define the getName method. All methods that should be exposed to the React Native layer need to have the @ReactMethod annotation. Creating a React Native Android native module has more overhead as compared with iOS, since you have to also wrap your module in a class that implements ReactPackage (in this recipe, that's the HelloPackage module), and register the package with the React Native project. This is done in steps 7 and 8.
In the JavaScript portion of the recipe, the greetUser function is executed when ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access