Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use paperTopLevelNameDeprecated in generated EventEmitters if defined (…
…#42812) Summary: Pull Request resolved: #42812 There is a way of defining events where you specify additional string type parameter in the EventHandler in the spec. This additional type parameter is an overridden top level event name, that can be completely unrelated to the event handler name. More context here D16042065. Let's say we have ``` onLegacyStyleEvent?: ?BubblingEventHandler<LegacyStyleEvent, 'alternativeLegacyName'> ``` This will produce the following entry in the view config: ``` topAlternativeLegacyName: { phasedRegistrationNames: { captured: 'onLegacyStyleEventCapture', bubbled: 'onLegacyStyleEvent' } } ``` This means that React expects `topAlternativeLegacyName`. But the generated EventEmitter looks like this: ``` void RNTMyNativeViewEventEmitter::onLegacyStyleEvent(OnLegacyStyleEvent $event) const { dispatchEvent("legacyStyleEvent", [$event=std::move($event)](jsi::Runtime &runtime) { auto $payload = jsi::Object(runtime); $payload.setProperty(runtime, "string", $event.string); return $payload; }); } ``` The native component will emit `legacyStyleEvent` (`topLegacyStyleEvent` after normalization) that React will not be able to handle. This issue only happens on iOS because Android doesn't use EventEmitter currently. To address this issue we'll use `paperTopLevelNameDeprecated` for the generated EventEmitters if it is defined. Changelog: [iOS][Fixed] - Fixed support for event name override in component specs. Reviewed By: cortinico, mdvacca, cipolleschi Differential Revision: D53310654 fbshipit-source-id: 018d5b11d8d36e2ecf900b9d8d6fe3e2ed71f80b
- Loading branch information