You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Docs] Improve Turbo Module docs for EventEmitter #1154
When writing a Turbo Module that contains an EventEmitter, you need to change your struct annotation from REACT_MODULE to REACT_TURBO_MODULE in order for the JS EventEmitter to be returned from the module.
It might be nice to include an example somewhere that shows a module that uses REACT_TURBO_MODULE and subscribes to the EventEmitter so users know when to use that over REACT_MODULE.
Motivation
I was running into an issue where I was trying to subscribe to an event in a turbo module:
But the function kept throwing an error saying that the function was undefined. After more troubleshooting than I care to admit, I eventually ran across this PR that mentions the usage of REACT_TURBO_MODULE. I was following the Native Modules docs and looking at this example and both of them use REACT_MODULE so I didn't know that REACT_TURBO_MODULE existed.
Yeah the docs should be updated to point to REACT_TURBO_MODULE as the default. At this point REACT_MODULE is sort of a legacy mode to be able to support older versions of RN that didn't have the native turbomodule event emitters, but instead used the JS eventemitters for events.
So if you module needs to support older RN versions, you cannot use the new event emitters.
Activity
acoates-ms commentedon Sep 15, 2025
Yeah the docs should be updated to point to REACT_TURBO_MODULE as the default. At this point REACT_MODULE is sort of a legacy mode to be able to support older versions of RN that didn't have the native turbomodule event emitters, but instead used the JS eventemitters for events.
So if you module needs to support older RN versions, you cannot use the new event emitters.