Skip to content

[Fast Refresh] Find and remount wrapper edits behind lazy() - #36965

Merged
sophiebits merged 1 commit into
mainfrom
fresh-type-changes/lazy-wrapper
Jul 8, 2026
Merged

[Fast Refresh] Find and remount wrapper edits behind lazy()#36965
sophiebits merged 1 commit into
mainfrom
fresh-type-changes/lazy-wrapper

Conversation

@sophiebits

@sophiebits sophiebits commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Two bugs:

  • Type changes to a lazy's inner component (e.g., adding a memo
    comparison function) were missed by the refresh scan.
  • If a SimpleMemoComponent needs to be remounted, previously
    resolveRemountTypeForHotReloading would return the inner function
    and we would incorrectly recreate the fiber as a FunctionComponent.
    Instead, we can just use elementType consistently now that the
    beginWork functions consistently call resolveFamily on the wrapped
    components.

@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Jul 8, 2026
@meta-cla meta-cla Bot added the CLA Signed label Jul 8, 2026
@sophiebits
sophiebits marked this pull request as ready for review July 8, 2026 07:20
@sophiebits
sophiebits requested a review from gaearon July 8, 2026 07:20
const outerFamily = resolve(payload._result.default);
if (outerFamily !== undefined && staleFamilies.has(outerFamily)) {
needsRemount = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix seems fine but factoring is a bit odd, since this inner block repeats the previous block (and has same first two conditions). Is there any benefit to unifying them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@sophiebits
sophiebits force-pushed the fresh-type-changes/lazy-wrapper branch from 6070edd to 2088495 Compare July 8, 2026 15:52
@sophiebits
sophiebits requested a review from gaearon July 8, 2026 15:52
@sophiebits
sophiebits force-pushed the fresh-type-changes/lazy-wrapper branch from 2088495 to 622335b Compare July 8, 2026 16:11
@sophiebits
sophiebits force-pushed the fresh-type-changes/lazy-wrapper branch from 622335b to bf24070 Compare July 8, 2026 16:56
Base automatically changed from fresh-type-changes/memo-comparison to main July 8, 2026 16:58
Two bugs:

- Type changes to a lazy's inner component (e.g., adding a `memo`
  comparison function) were missed by the refresh scan.
- If a SimpleMemoComponent needs to be remounted, previously
  resolveRemountTypeForHotReloading would return the inner function
  and we would incorrectly recreate the fiber as a FunctionComponent.
  Instead, we can just use elementType consistently now that the
  beginWork functions consistently call resolveFamily on the wrapped
  components.
@sophiebits
sophiebits force-pushed the fresh-type-changes/lazy-wrapper branch from bf24070 to c76488d Compare July 8, 2026 16:58
@sophiebits
sophiebits merged commit 5123b06 into main Jul 8, 2026
13 checks passed
@sophiebits

Copy link
Copy Markdown
Contributor Author

@hoxyq ty!

@react-sizebot

Copy link
Copy Markdown

Comparing: 4400d6c...c76488d

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 = 7.19 kB 7.19 kB +0.05% 1.91 kB 1.91 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 614.54 kB 614.54 kB = 108.61 kB 108.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.19 kB 7.19 kB +0.05% 1.91 kB 1.91 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 685.73 kB 685.73 kB = 120.11 kB 120.11 kB
facebook-www/ReactDOM-prod.classic.js = 706.08 kB 706.08 kB = 123.69 kB 123.69 kB
facebook-www/ReactDOM-prod.modern.js = 696.39 kB 696.39 kB = 122.07 kB 122.07 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against c76488d

github-actions Bot pushed a commit to code/lib-react that referenced this pull request Jul 10, 2026
)

Two bugs:

- Type changes to a lazy's inner component (e.g., adding a `memo`
  comparison function) were missed by the refresh scan.
- If a SimpleMemoComponent needs to be remounted, previously
  resolveRemountTypeForHotReloading would return the inner function
  and we would incorrectly recreate the fiber as a FunctionComponent.
  Instead, we can just use elementType consistently now that the
  beginWork functions consistently call resolveFamily on the wrapped
  components.

DiffTrain build for [5123b06](react@5123b06)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Jul 10, 2026
)

Two bugs:

- Type changes to a lazy's inner component (e.g., adding a `memo`
  comparison function) were missed by the refresh scan.
- If a SimpleMemoComponent needs to be remounted, previously
  resolveRemountTypeForHotReloading would return the inner function
  and we would incorrectly recreate the fiber as a FunctionComponent.
  Instead, we can just use elementType consistently now that the
  beginWork functions consistently call resolveFamily on the wrapped
  components.

DiffTrain build for [5123b06](react@5123b06)
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.

4 participants