Skip to content

RN: Switch EventEmitter to Array.from(...) - #39525

Closed
yungsters wants to merge 1 commit into
react:mainfrom
yungsters:export-D49389813
Closed

RN: Switch EventEmitter to Array.from(...)#39525
yungsters wants to merge 1 commit into
react:mainfrom
yungsters:export-D49389813

Conversation

@yungsters

Copy link
Copy Markdown
Contributor

Summary:
Switches EventEmitter#emit to use Array.from instead of the spread operator.

This should be functionally identical (with marginally less overhead of the runtime having to determine the type of registrations), but there seems to be some unexpected Babel configurations in the community that causes this line of code to do the wrong things.

Although we should independently root cause the Babel plugin configuration problems, this change might provide immediate relief and is also not any worse (e.g. in terms of code readability). This also adds a descriptive comment explaining the intention of the call to Array.from.

Changelog:
[Fixed][General] - Fix a potential bug in EventEmitter when used with certain Babel configurations that incorrectly polyfill the spread operator for iterables.

Differential Revision: D49389813

@facebook-github-botfacebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 18, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actionsBot commented Sep 18, 2023

Copy link
Copy Markdown
Warnings
⚠️One hour and a half have passed and the E2E jobs haven't finished yet.

Generated by 🚫 dangerJS against eafd035

Summary:
Switches `EventEmitter#emit` to use `Array.from` instead of the spread operator.
This should be functionally identical (with marginally less overhead of the runtime having to determine the type of `registrations`), but there seems to be [some unexpected Babel configurations in the community](react#35577 (comment)) that causes this line of code to do the wrong things.
Although we should independently root cause the Babel plugin configuration problems, this change might provide immediate relief and is also not any worse (e.g. in terms of code readability). This also adds a descriptive comment explaining the intention of the call to `Array.from`.
Changelog:
[Fixed][General] - Fix a potential bug in `EventEmitter` when used with certain Babel configurations that incorrectly polyfill the spread operator for iterables.
Reviewed By: javache
Differential Revision: D49389813
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 8b768f1.

@guptaprnv

Copy link
Copy Markdown

@yungsters is react native planning a release with this in react native 72 version

@yungsters

Copy link
Copy Markdown
ContributorAuthor

@yungsters is react native planning a release with this in react native 72 version

Thanks for the poke; I've requested this fix for the next patch release in reactwg/react-native-releases#89.

huntie pushed a commit that referenced this pull request Oct 11, 2023
Summary:
Pull Request resolved: #39525
Switches `EventEmitter#emit` to use `Array.from` instead of the spread operator.
This should be functionally identical (with marginally less overhead of the runtime having to determine the type of `registrations`), but there seems to be [some unexpected Babel configurations in the community](#35577 (comment)) that causes this line of code to do the wrong things.
Although we should independently root cause the Babel plugin configuration problems, this change might provide immediate relief and is also not any worse (e.g. in terms of code readability). This also adds a descriptive comment explaining the intention of the call to `Array.from`.
Changelog:
[Fixed][General] - Fix a potential bug in `EventEmitter` when used with certain Babel configurations that incorrectly polyfill the spread operator for iterables.
Reviewed By: javache
Differential Revision: D49389813
fbshipit-source-id: 7caf63734fc047496afe2f1ed6d918c22747258a
Saadnajmi added a commit to microsoft/react-native-macos that referenced this pull request Oct 16, 2023
* Move hermes-engine.podspec and hermes-utils.rb from hermes-engine to hermes folders when building (react#39575)
* Update Xcode 15 patches to be more robust (react#39710)
Summary:
Pull Request resolved: react#39710
Last week Apple released Xcode 15, which required us to ship a workaround for the new linker.
Unfortunately, the previous fix was not good enough and there were some edge cases that were not covered.
For example, in some occasions the flags are read as an array and the `-Wl` and the `-ld_classic` flags were separated and not properly removed when moving from Xcode 15 to Xcpde 14.3.1.
This change fixes those edge cases, with a more robust solution where:
- We convert the flags to a string.
- We trim the string and the values properly.
- We add the flags when running `pod install` with Xcode 15 as the default iOS toolchain.
- We remove the flags when running `pod install` with Xcode <15 as the default iOS toolchain.
## Changelog:
[Internal] - Make the Xcode 15 workaround more robust.
Reviewed By: dmytrorykun
Differential Revision: D49748844
fbshipit-source-id: 34976d148f123c5aacba6487a500874bb938fe99
# Conflicts:
#	packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
#	packages/react-native/scripts/cocoapods/utils.rb
* Fix Gemfile, setting Active support to < 7.1.0 (react#39828)
Summary:
Pull Request resolved: react#39828
Active Suppert released a new Gem which is incompatible with Cocoapods 1.13.0, the latest release, as they removed a method used by cocoapods.
This fix ensures that we install compatible versions of the Gem.
## Changelog:
[iOS][Fixed] - Set the max version of Active support to 7.0.8
Reviewed By: hoxyq
Differential Revision: D49949782
fbshipit-source-id: 278097502d3a416567cc8c0b90090fee4fb21503
# Conflicts:
#	Gemfile
* RN: Switch EventEmitter to `Array.from(...)` (react#39525)
Summary:
Pull Request resolved: react#39525
Switches `EventEmitter#emit` to use `Array.from` instead of the spread operator.
This should be functionally identical (with marginally less overhead of the runtime having to determine the type of `registrations`), but there seems to be [some unexpected Babel configurations in the community](react#35577 (comment)) that causes this line of code to do the wrong things.
Although we should independently root cause the Babel plugin configuration problems, this change might provide immediate relief and is also not any worse (e.g. in terms of code readability). This also adds a descriptive comment explaining the intention of the call to `Array.from`.
Changelog:
[Fixed][General] - Fix a potential bug in `EventEmitter` when used with certain Babel configurations that incorrectly polyfill the spread operator for iterables.
Reviewed By: javache
Differential Revision: D49389813
fbshipit-source-id: 7caf63734fc047496afe2f1ed6d918c22747258a
* [Local] Fix CI for 0.72, with Acitve Support and Xcode15 (react#40855)
* [0.72.6] Bump version numbers
* Bump deprecated-react-native-prop-types to ^4.2.3
This version correctly sets a dependency on `"@react-native/normalize-colors": "<0.73.0"` (from `"*"`), preventing future unwanted breakages.
* Fix broken Loading/Refreshing indicator on Android
Summary:
The Loading.../Refreshing... indicator is currently broken on Android.
The reason is related to D42599220
We used to have a Toast shown to users on Android as a fallback, but as the
DevLoadingView is not always loaded as a module in the core package, this ends up in the banner never beign shown to the user (on RN Tester or template apps).
Changelog:
[Android] [Fixed] - Fix broken Loading/Refreshing indicator on Android
Reviewed By: cipolleschi
Differential Revision: D49876757
fbshipit-source-id: 400e002327ebca908e3e7a7f81c5066888ac4e9b
---------
Co-authored-by: Riccardo Cipolleschi <cipolleschi@meta.com>
Co-authored-by: Tim Yung <yungsters@meta.com>
Co-authored-by: Distiller <distiller@static.38.39.185.90.cyberlynk.net>
Co-authored-by: Alex Hunt <hello@alexhunt.io>
Co-authored-by: Nicola Corti <ncor@meta.com>
@yungsters
yungsters deleted the export-D49389813 branch March 13, 2025 16:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.fb-exportedMergedThis PR has been merged.p: FacebookPartner: FacebookPartner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@yungsters@facebook-github-bot@guptaprnv