-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create React App + Hot Reloading not working? #1188
Comments
Could you make a demo project? There's not much details about the |
Yes, you can check out my project here https://github.com/tomasruud/downcloud |
Hello, HMR really does not work by default, and actually it is not related to CRA, the same thing happens in clean project as well. At first I thought it is caused by stateless functional components syntax, because I was sure that I used Styleguidist year ago with class components and it did work well. So I tested all possible component definitions and saw it is not related to actual syntax. I created minimal example project so anybody can look further into it.
Edit: Seems it is caused by some webpack caching bug. HMR works again when Example project link: https://github.com/malyzeli/styleguidist-issue-1188-example |
|
Feel free to send a pull request with a fix 👾 |
Is the Im on CRA 2.1.1 with styleguidist 8.0.6 and it does not seem to work for me either. The HMR network requests do not even fire in my case, so I think it could be different problem than just the caching. Im seeing the same behavior in the styleguidist v9 beta branch as well |
@seanlaff I'm sorry, never used CRA so I can't help you with that.. @tomasruud Since maintainers of this repo ignore request to reopen #1206, would you mind removing CRA from name of this issue? I believe claiming explicitly that HMR does not work in general (which is apparently true) could attract more attention and hopefully got it fixed sooner. I'm surprised that not many people noticed.. Maybe experienced developers able to fix it are not using CRA? :D |
@malyzeli Hot Reload works as I'd expect in your https://github.com/malyzeli/styleguidist-issue-1188-example repo (I'm on mac mojave), so I think the designation of CRA is correct for this issue. I dug in some more and realized that as soon as the styleguidist webpage loads in a CRA repo, this message is output to the web console
which explains why I don't see updates. Not sure what causes the disconnect yet. |
I think I've found the problem. It would appear that Styleguidist HMR is broken by webpack-dev-server > 3.1.10 for both CRA and non-CRA rrepos. The reason it appeared to be working in @malyzeli repo was because their yarn.lock had |
@seanlaff I've not been working on the project that much lately, so I don't know to be honest. But I would assume the issue is still there.
@malyzeli If this was a problem for all users of Styleguidist, more people would probably have noticed. Which in turn would have produced more activity on this issue and yours as well. I would assume in your case, that it's a rare edge case that by chance matches my CRA issue.
In my project webpack-dev-server is locked at 3.1.9 for react-scripts, and 3.1.10 for styleguidist, so this might be true. Were you able to get it to work by updaing webpack-dev-server @seanlaff ? |
Looking at the updates to dev-server, I suspect this is might be what caused it webpack/webpack-dev-server#1603 ... although that MR would lead me to believe I'd see invalid host errors, so perhaps it could be something else. |
Here's my workaround. It works by short-circuiting the header check that webpack-dev-server added. This poses a security risk.
module.exports = {
dangerouslyUpdateWebpackConfig(config) {
if (!config.devServer) {
config.devServer = {};
}
config.devServer.disableHostCheck = true;
return config;
}
}; This leads me to believe webpack/webpack-dev-server#1603 is in-fact the root cause, but I still don't have a good explanation of why we don't see the invalid host errors. |
😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature. |
No, it does not work |
It's been half a year, of course everything is different today - that's JavaScript, dude! |
@wzup import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
const rootEl = document.getElementById('root')
ReactDOM.render(
<App />,
rootEl
)
if (module.hot) {
module.hot.accept('./App', () => {
const NextApp = require('./App').default
ReactDOM.render(
<NextApp />,
rootEl
)
})
} |
Was this resolved? It's still not working |
(not related to For my broken hot-reload on CRA it worked updating to versions:
|
Current behavior
When I try to use react-styleguidist with CRA, without changing the config, it seems like hot reloading are not working properly. Whenever I update my code, I am able to see the source refresh in the inspector, but nothing changes on the page. However, when I add
to my styleguide-config file, it's working as expected.
To reproduce
Here are my current set of dependencies and scripts
I'm using css modules which comes with CRA.
Here is an example component:
Expected behavior
I would expect this to work straight out of the box.
The text was updated successfully, but these errors were encountered: