Skip to content

Swap react-loadable to the patched one#12311

Draft
seyoon20087 wants to merge 5 commits into
facebook:mainfrom
seyoon20087:swap-react-loadable
Draft

Swap react-loadable to the patched one#12311
seyoon20087 wants to merge 5 commits into
facebook:mainfrom
seyoon20087:swap-react-loadable

Conversation

@seyoon20087

@seyoon20087 seyoon20087 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Currently, the version of react-loadable used is @docusaurus/react-loadable.

While I greatly appreciate their version of react-loadable, I found that it uses UNSAFE_componentWillMount under the hood, which is not safe in strict-mode.

Additionally, as we don't know when React will remove such lifecycle methods (they could eventually do so in the future), I swapped the version of react-loadable to my one in advance.

(While @react-loadable/revised or loadable-components are other alternatives too, the API and types aren't fully backwards-compatible, which is why my attempts to fix it were failed previously.)

I have tested this change internally, and found that all functionality works (including server-side-rendering).

I hope this attempt will go well.

(All APIs and types are identical from the upstream react-loadable, which means not many code changes are required)

  • NOTE: because of the "minimumReleaseAge" setting, my @seyoon20087/react-loadable package's latest version was temporarily added in the "minimumReleaseAgeExclude" setting of pnpm-workspace.yaml.

If you don't want to use my own copy of the package directly, please refer to the source code of my package (https://github.com/seyoon20087/react-loadable-revised) and make changes directly.

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Currently, the version of react-loadable used is @docusaurus/react-loadable.

While I greatly appreciate their version of react-loadable, I found that it uses UNSAFE_componentWillMount under the hood, which is not safe in strict-mode.

Additionally, as we don't know when React will remove such lifecycle methods (they could eventually do so in the future).

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Fix for #6306 (review)

Currently, the version of react-loadable used is `@docusaurus/react-loadable`.

While I greatly appreciate their version of react-loadable,
I found that it uses UNSAFE_componentWillMount under the hood,
which is not safe in strict-mode.

Additionally, as we don't know when React
will remove such lifecycle methods
(they *could* eventually do so in the future),
I swapped the version of react-loadable to my one in advance.

While `@react-loadable/revised` or `loadable-components`
are other alternatives too, the API and types
aren't fully backwards-compatible, which is why
my attempts to fix it were failed previously.

I have tested this change internally, and found that all functionality
works (including server-side-rendering).

I hope this attempt will go well.

(All APIs and types are identical from the upstream react-loadable,
which means not many code changes are required)

- NOTE: because of the "minimumReleaseAge" setting,
  my `@seyoon20087/react-loadable` package's latest version was temporarily
  added in the "minimumReleaseAgeExclude" setting of pnpm-workspace.yaml.

Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com>
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jul 23, 2026
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit c454d6d
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a6207dbe6d755000869c5a7
😎 Deploy Preview https://deploy-preview-12311--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Your version has a lot of commits: https://github.com/seyoon20087/react-loadable-revised/commits/main/

We don't want to fully refactor that legacy library, but simply fix the UNSAFE issue

Please submit a minimal PR to our fork and we'll release a new version: https://github.com/slorber/react-loadable

Really keep it minimal. As far as I see from my local tests, just moving this._loadModule(); in the constructor is enough. If that's not the case, please explain why.

We are not looking to modernize this lib for the whole frontend community, just trying to solve our own needs.

"@types/react-router-dom": "*",
"react-helmet-async": "npm:@slorber/react-helmet-async@1.3.0",
"react-loadable": "npm:@docusaurus/react-loadable@6.0.0"
"react-loadable": "npm:@seyoon20087/react-loadable@^6.0.2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We want to keep using our fork, not someone else's fork

@seyoon20087

Copy link
Copy Markdown
Contributor Author

Please submit a minimal PR to our fork and we'll release a new version: https://github.com/slorber/react-loadable

Can you take a look at my PR in that repo? slorber/react-loadable#1

@slorber

slorber commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Hey

This code should work: #12313

Please do the same in your PR

We don't really care about this lib's internal existing jest test, but only want to make sure it works for us at runtime. The best way to validate this against Docusaurus is to submit a local patch here, and if it works we'll patch the dependency.

- undo all changes made by me
- changes according to facebook#12313

Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com>
Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com>
@seyoon20087 seyoon20087 changed the title Swap react-loadable to my one of react-loadable Swap react-loadable to the patched one Jul 23, 2026
Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com>
@seyoon20087
seyoon20087 requested a review from slorber July 23, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants