Skip to content

[Bugfix] Don't double invoke effects for list reorders - #35952

Open
rickhanlonii wants to merge 2 commits into
react:mainfrom
rickhanlonii:rh/strict-mode-list
Open

rickhanlonii wants to merge 2 commits into
react:mainfrom
rickhanlonii:rh/strict-mode-list

Conversation

@rickhanlonii

@rickhanlonii rickhanlonii commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #32561

In placeChild, the move case was setting PlacementDEV in addition to
Placement. PlacementDEV is meant to identify newly inserted fibers so
that StrictMode can double-invoke their effects on mount. Moved fibers
are not new insertions, so they should not have PlacementDEV set.

This matches the behavior of placeSingleChild, which only sets
PlacementDEV when alternate === null (i.e., a true insertion).
Add two tests that verify the StrictMode PlacementDEV fix handles
mixed scenarios correctly:
- Move + new mount: only the new item's effects are double-invoked
- Move + removal: only the removed item's cleanup effects fire
@rickhanlonii
rickhanlonii requested a review from acdlite March 3, 2026 16:59
@meta-cla meta-cla Bot added the CLA Signed label Mar 3, 2026
@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Mar 3, 2026
@react-sizebot

Copy link
Copy Markdown

Comparing: 4cc5b7a...e05c062

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 611.79 kB 611.78 kB = 108.12 kB 108.11 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 677.72 kB 677.71 kB = 119.08 kB 119.08 kB
facebook-www/ReactDOM-prod.classic.js = 697.72 kB 697.71 kB = 122.59 kB 122.59 kB
facebook-www/ReactDOM-prod.modern.js = 688.03 kB 688.03 kB = 120.97 kB 120.97 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against e05c062

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: StrictMode reruns effects when a child is moved in an array

2 participants