clauderic / clauderic/dnd-kit

React 19: DragDropProvider manager is destroyed during Strict Mode replay

Open
#2,116 1 comment 0 reactions 0 assignees View on GitHub
bug react triage:done
Dominant language
TypeScript
Stars
17.6k
Forks
924
Avg merge
2d 10h
Merged PRs (30d)
2

Description

## 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.

```tsx



```

## 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.

Contributor guide

Open the contributing guide

Research direction

Start by locating useStableInstance and its useInsertionEffect cleanup. Reproduce the issue with React 19 StrictMode, then inspect the Storybook regression story and Playwright coverage mentioned in the issue. Done means the mounted provider keeps its manager usable after development-only Effect replay and the regression coverage passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.