Purpose of RCTBridgeModule and ReactContextBaseJavaModule
understanding the native module contract.
these declare a class as a discoverable native module, provide the JS-facing name, and let RN export methods to JavaScript.
WHAT THIS TESTS The interviewer checks whether you understand the role these base abstractions play: they are the registration and exposure contract that turns a plain native class into a callable React Native module.
A GOOD ANSWER COVERS ReactContextBaseJavaModule on Android is the base class your native module extends. It receives the ReactApplicationContext, gives you a place to implement getName (the identifier JavaScript uses under NativeModules), and works with the @ReactMethod annotation so the framework can discover and bridge your methods to JS. RCTBridgeModule is the iOS protocol that a native module class conforms to; together with the RCT_EXPORT_MODULE macro it registers the class with the bridge and exposes methods declared with RCT_EXPORT_METHOD. In short, both define the contract that lets the React Native runtime find the module, know its name, and marshal calls and arguments between JavaScript and the native method implementations, and they provide access to the React context for reaching app and activity state. They concern native logic and platform APIs, not UI rendering, which is the separate job of view managers (RCTViewManager / ViewManager).
COMMON WRONG ANSWERS Saying they render or manage native views confuses native modules with view managers; modules expose methods, not components. Claiming they create or own the JavaScript engine is wrong; the bridge and runtime do that. Thinking the base type alone exposes methods without @ReactMethod or RCT_EXPORT_METHOD misses that the annotations/macros mark which methods cross over.
LIKELY FOLLOW-UPS What is the difference between a native module and a view manager? Modules expose imperative methods; view managers expose native UI components. How does getName matter? It is the key under NativeModules in JS. How are arguments marshaled? Through serialization on the legacy bridge, or via JSI on the new architecture.
ONE CONCRETE EXAMPLE A DeviceInfoModule extends ReactContextBaseJavaModule, returns "DeviceInfo" from getName, and exposes a @ReactMethod getBatteryLevel. On iOS the same module conforms to RCTBridgeModule, uses RCT_EXPORT_MODULE(), and RCT_EXPORT_METHOD(getBatteryLevel:...). JS then calls NativeModules.DeviceInfo.getBatteryLevel, which only works because these base types registered and exposed it.
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.