react-native
react-native copied to clipboard
Use paperTopLevelNameDeprecated in generated EventEmitters if defined
Summary: 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.
Differential Revision: D53310654
This pull request was exported from Phabricator. Differential Revision: D53310654
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
android | hermes | arm64-v8a | 17,246,949 | +2 |
android | hermes | armeabi-v7a | n/a | -- |
android | hermes | x86 | n/a | -- |
android | hermes | x86_64 | n/a | -- |
android | jsc | arm64-v8a | 20,609,338 | -12 |
android | jsc | armeabi-v7a | n/a | -- |
android | jsc | x86 | n/a | -- |
android | jsc | x86_64 | n/a | -- |
Base commit: 4d07aae7efacf758967e12472f8d9f1f803c5238 Branch: main
This pull request was exported from Phabricator. Differential Revision: D53310654
This pull request was exported from Phabricator. Differential Revision: D53310654
This pull request was exported from Phabricator. Differential Revision: D53310654
This pull request has been merged in facebook/react-native@6974697b049eff0038a17e3ebf962ec7451a5aa4.
While preparing react-native-screens
release to work in bridgeless mode I encountered this error on Fabric when bridgeless is disabled. Is this PR the reason why it is appearing?
I can provide a repro if needed.
While preparing
react-native-screens
release to work in bridgeless mode I encountered this error on Fabric when bridgeless is disabled. Is this PR the reason why it is appearing?I can provide a repro if needed.
Are you on a older version of react-native-safe-area-context
by any chance?
Yeah, it was it 😅 On rc1 of screens all is well!