Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use paperTopLevelNameDeprecated in generated EventEmitters if defined #42812

Closed
wants to merge 1 commit into from

Conversation

dmytrorykun
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Feb 2, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53310654

@analysis-bot
Copy link

analysis-bot commented Feb 2, 2024

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: 4d07aae
Branch: main

dmytrorykun added a commit to dmytrorykun/react-native that referenced this pull request Feb 2, 2024
…facebook#42812)

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.

Reviewed By: cortinico

Differential Revision: D53310654
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53310654

dmytrorykun added a commit to dmytrorykun/react-native that referenced this pull request Feb 5, 2024
…facebook#42812)

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.

Reviewed By: cortinico, mdvacca

Differential Revision: D53310654
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53310654

dmytrorykun added a commit to dmytrorykun/react-native that referenced this pull request Feb 12, 2024
…facebook#42812)

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.

Reviewed By: cortinico, mdvacca

Differential Revision: D53310654
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53310654

…facebook#42812)

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.

Reviewed By: cortinico, mdvacca, cipolleschi

Differential Revision: D53310654
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6974697.

@tjzel
Copy link
Contributor

tjzel commented Mar 21, 2024

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.

Screenshot 2024-03-21 at 12 01 55

@cortinico
Copy link
Contributor

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?

@tjzel
Copy link
Contributor

tjzel commented Mar 21, 2024

Yeah, it was it 😅 On rc1 of screens all is well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants