Skip to content

EventEmitter rejects event names inherited from Object.prototype #58228

Description

@OskarEichler

Description

The shared React Native EventEmitter stores listener registrations in an ordinary object. Valid string event names such as constructor and __proto__ therefore resolve inherited prototype values; addListener attempts to call .add on them and throws before registration.

Expected behavior

Every valid string key should be independently registrable, emitted, counted, and cleared, including names that overlap Object.prototype. removeAllListeners() should reset to the same prototype-free registry.

React Native Version

0.87.1 and current main

Affected Platforms

JavaScript runtime - All

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions