-
-
Notifications
You must be signed in to change notification settings - Fork 238
HMR not working when lazy loading Class component wrapped in Hoc #133
Copy link
Copy link
Closed
vitejs/vite-plugin-react-swc
#203Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Trying to migrate an older create-react-app to Vite i ran in to the following issue:
When a Class component is lazy loaded using React.lazy and the component is wrapped in a Hoc then HMR stops working.
The browser has to be refreshed manually to show changes.
When React.lazy is removed HMR works.
Also when using @loadable/component instead of React.lazy HMR works.
CleanShot.2023-04-04.at.09.56.35.mp4
See minimal reproduction in codesandbox below:
Reproduction
https://codesandbox.io/p/sandbox/elated-dawn-tvd36y?file=%2Fsrc%2FApp.tsx
Steps to reproduce
- Open codesandbox
- Edit the file ClassComponentWithHoc.tsx
- Save the changes
Result: The browser will not update the output unless you manually click the refresh button of the browser window.
System Info
System:
OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (2) x64 AMD EPYC
Memory: 409.07 MB / 1.63 GB
Container: Yes
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.15.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.5.0 - /usr/local/bin/npm
npmPackages:
@vitejs/plugin-react: ^3.1.0 => 3.1.0
vite: ^4.1.1 => 4.2.1Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working