Rival compares React Native’s bridge with ways other frameworks connect JavaScript to native code. Messages between JavaScript and native code are asynchronous, and calls carry a module ID, method ID, and arguments. Common values such as numbers, strings, arrays, objects, and promises are supported.
Building native modules for React Native
Speaker
Florian Rival, a software engineer at Baim, explains how to build and maintain React Native native modules, drawing on his work on React Native Image Resizer at a Callstack event.
For iOS, Rival describes adding an Objective-C file and exposing its module and methods with React Native macros. On Android, developers create a Java module and register its package in the application class. Both platforms require rebuilding the app, but a basic method can be called without much extra glue code.
Rival recommends keeping a blank React Native app in the module repository so developers can test the latest local version and contributors can check that it works. During development, console messages, Xcode and Android Studio debuggers, and native view inspectors help diagnose issues. RN Snoopy or `MessageQueue.spy` can reveal bridge traffic, while Instruments and Android Monitor help track memory use.
Rival says to handle native exceptions and watch for excessive bridge traffic, which can slow the app and contribute to flicker in highly interactive features. React Native Image Resizer keeps image contents off the bridge because they can weigh several megabytes; it uses file paths instead. Native memory tools can help identify resource problems, including those caused by large images.
Rival distinguishes breaking changes in a module from changes in React Native’s native interfaces. He recommends semantic versioning, with a major version increase for breaking changes, and mentions Commitizen as a way to track them. Changes such as iOS header path updates can require a new, incompatible module release.
Takeaways
- Keep a small React Native test app in the module repository so changes can be checked against the latest local code.
- Use native debuggers and view inspectors when JavaScript tools cannot show what is happening in native code.
- Profile bridge traffic when interactive features slow down, and avoid sending large files or image data through the bridge.
- Use file paths to pass large assets between JavaScript and native code.
- Track breaking changes in both the module and React Native, and use major version bumps when compatibility changes.
Mentioned in this talk
Search inside this talk
What was claimed 9
- featureBaim: Builds mobile applications
“we build mobile applications”
YouTube Unverified1 source· Talk
- role atFlorian Rival is software engineer at Baim
“I'm a software engineer at Baim.”
YouTube Unverified1 source· Talk
- featureReact Native Image Resizer: Reduces image size
“create a native module to reduce its size”
YouTube Unverified1 source· Talk
- built
“That's how we created React Native Image Resizer”
YouTube Unverified1 source· Talk
- featureGDevelop: Lets people create games without programming
“software you can use to create games without programming”
YouTube Unverified1 source· Talk
- builtFlorian Rival built GDevelop
“I'm also the author of GDevelop.”
YouTube Unverified1 source· Talk
- featureReact Native: Native-to-JavaScript and JavaScript-to-native messages are asynchronous
“every message sent from native to JavaScript, or from JavaScript to native, is asynchronous”
YouTube Unverified1 source· Talk
- featureReact Native Image Resizer: Uses file paths instead of sending image contents over the bridge
“we don’t send image contents over the bridge”
YouTube Unverified1 source· Talk
- uses
“My advice is to follow semantic versioning”
YouTube Unverified1 source· Talk






