Skip to content

React 19: DragDropProvider manager is destroyed during Strict Mode replay #2116

Description

@mnlttt

Description

In React 19 development with StrictMode enabled, DragDropProvider can retain a manager instance after that instance has been destroyed during React’s development-only Effect replay.

useStableInstance creates the manager once and stores it in a ref, but its cleanup currently destroys ref.current from useInsertionEffect. The replayed lifecycle can therefore leave the mounted provider holding a destroyed manager.

Reproduction

  1. Use React 19 in development mode with StrictMode enabled.
  2. Render a DragDropProvider containing a draggable element.
  3. Interact with the draggable element after the initial mount.
<StrictMode>
  <DragDropProvider>
    <Draggable />
  </DragDropProvider>
</StrictMode>

Expected behavior

The manager should remain usable for as long as its DragDropProvider remains mounted.

Actual behavior

The provider can retain a manager that has already been destroyed, so later drag interactions may fail.

Proposed direction

Move manager disposal out of useInsertionEffect and defer cleanup enough to distinguish the development-only Strict Mode replay from a real unmount.

I have a focused patch with a Storybook regression story and Playwright coverage ready to link in a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreactReact packagetriage:doneIssue has been triaged by automation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions