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
[HMR] Styles not updating with v2.2.1 #1225
Comments
Yep, very likely. Good catch, @schwers any idea how we can detect HMR? Should we turn off caching in development? |
Ah ha! Just realized this is what's breaking styled-components hot reloading for react-static users. Looks like I'm gonna have to lock things down to 2.2.0 until it's fixed. |
@PiereDome sorry about that, if by chance its only affecting @mxstbr I'll have to try out something with HMR. I would think if the component is re-evaluated we wouldn't have to do anything. i.e. a |
@schwers I am not using |
Okay, gotcha. I'll try repro'ing later today. If you're able to provide any
minimal examples of a SC that stay stale that'd be awesome.
…On Oct 9, 2017 1:13 PM, "Brian Pedersen" ***@***.***> wrote:
@schwers <https://github.com/schwers> I am not using attrs in my
StyledComponents. It did seem to work when I was using the connect HOC
from react-redux but not 100% sure that was the reason it was working. I
can further try to narrow the working vs non-working components if you need
me to.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1225 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASzDymd84KD7fU0smACn4MmdlI5wAKBks5sqn5PgaJpZM4Pyt_Y>
.
|
Looks like if you have a function call inside the styledComponent the HMR will work. i.e. |
As @PiereDome mentioned - HRM start working when you do have function inside style, ie style is not static. componentWillReceiveProps(nextProps: { theme?: Theme, [key: string]: any }) {
// If this is a staticaly-styled component, we don't need to listen to
// props changes to update styles
const { componentStyle } = this.constructor
if (componentStyle.isStatic) {
return
} So, just replace it by if (!module.hot && componentStyle.isStatic) {
return
} PS: |
Hmm, that could work but might break some folks if they don't use webpack. Maybe if they properly guard against it? |
const isHMREnabled = () => typeof module !== 'undefined' && module.hot Should I create a PR, or you can manage this by your own? |
Please create a PR! |
Any news on this? |
@cr0cK - was releases a month ago - v2.2.4 |
Oh sorry. But it still doesn't work for me. |
@cr0cK Did you figure it out? I'm having the same problem at v2.4.0. |
@elliothimmelfarb - just post an example, and we will figure out which part is broken - HRM, RHL or Styled. |
@theKashey
Is that telling? |
@elliothimmelfarb - it is about - StyledComponent could cause a state loss, as long it got updated. |
@theKashey That did it! Thank you so much! |
I'm having this issue with storybook 4.0.11 and styled-components 3.4.10 Any ideas? |
Version
2.2.1
babel-plugin-styled-components version: N/A
Reproduction
HMR is broken for styled component styles with upgrade from 2.2.0 to 2.2.1. I believe that the culprit may be #1069. Perhaps we could do a check if the code is running in dev environment and not cache the statics then.
Steps to reproduce
Run webpack-dev-server with HMR using the react-hot-loader plugin
Expected Behavior
When I change a style attribute in my styledComponent I would expect the style to change in the browser without a full page refresh. I did test that this is working in 2.2.0.
Actual Behavior
The style change does not happen until I do a full page refresh
The text was updated successfully, but these errors were encountered: