Skip to content

Bug: performance: createPortal() attaches listeners even in contained roots #33428

Open
@romgrk

Description

@romgrk

I'm working on a new virtualization engine for the MUI X Data Grid and other components. I was hoping to be able to do some work outside of react for performance reasons, and to tie React in with portals, but the base cost of adding portals is too high for that use-case due to the event listeners that are added on new roots.

React version: 19

Steps To Reproduce

  1. Create a portal inside the app's main root

Link to code example: https://stackblitz.com/edit/mui-virtual-exploration

The current behavior

React attaches event listeners to new portal roots even when the root node is contained by the main app root node. It creates a lot of overhead for cases where multiple portals are attached at once.

The expected behavior

No added listeners if the root is contained in the main root.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions