How do you send a one-off event from native to JS?
native-to-JS communication basics.
emit an event from native using an event emitter and subscribe in JS with NativeEventEmitter, or resolve a promise/callback for a single result.
WHAT THIS TESTS: Familiarity with the standard mechanisms native code uses to push information up to JavaScript, and the difference between a broadcast event and a scoped response.
A GOOD ANSWER COVERS: Native code cannot call arbitrary JavaScript functions directly; it sends data through defined channels. For notifications and broadcasts, the native module emits a named event using the device or module event emitter, and JavaScript subscribes with NativeEventEmitter by calling addListener with the event name and a handler, then removing that subscription on cleanup. For a single result that belongs to a specific request, the cleaner pattern is to expose a method that returns a Promise or takes a callback, so the native side resolves it once with the completion data instead of broadcasting to all listeners.
COMMON WRONG ANSWERS: Claiming native can directly invoke a named JS function. Using a broadcast event for a one-off result where a Promise is more appropriate, leading to handlers firing for unrelated callers. Forgetting to remove the listener, which leaks and produces duplicate handling after remounts.
LIKELY FOLLOW-UPS: Difference between events and Promises, how this works under the new architecture with TurboModules and JSI, where to register supported events on the native side, and how to avoid listener leaks in useEffect.
ONE CONCRETE EXAMPLE: A native upload task finishing emits an UploadComplete event with the file id. JavaScript subscribes in a useEffect, updates state when the event arrives, and returns a cleanup function that removes the subscription. If only the caller cares, the upload method instead returns a Promise that resolves with the file id when done.
Read the original → reactnative.dev
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.