Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with webpack-hot-middleware, issues #784

Open
NaHuGD opened this issue Nov 3, 2023 · 0 comments
Open

Using with webpack-hot-middleware, issues #784

NaHuGD opened this issue Nov 3, 2023 · 0 comments

Comments

@NaHuGD
Copy link

NaHuGD commented Nov 3, 2023

"react": "18.2.0",
"webpack": "^5.73.0",
"webpack-dev-middleware": "^5.3.3",
"webpack-hot-middleware": "^2.25.1",
"react-refresh": "^0.14.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",

My project utilizes react18 createRoot for rendering and is configured with Node Express(), webpack-dev-middleware, and webpack-hot-middleware.
After upgrading from webpack 4 to webpack 5, I faced an issue where the webpack-hot-middleware didn't hot reload the view after API updates.
To address this issue, I decided to use the react-refresh-webpack-plugin, which resolved the problem. However, it introduced another issue: after API updates, an error would occur.
Warning: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.
I managed to resolve this issue by removing the if (module.hot) { module.hot.accept() } from index.js. Is this a valid solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant