Swap react-loadable to the patched one#12311
Conversation
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>
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
slorber
left a comment
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
We want to keep using our fork, not someone else's fork
Can you take a look at my PR in that repo? slorber/react-loadable#1 |
|
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>
Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com>
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/revisedorloadable-componentsare 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)
@seyoon20087/react-loadablepackage'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
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)