-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Styled JSX does not hot reload #2269
Comments
I also had a similar problem today, and it was resolved by ensuring that the plugin "styled-jsx/babel" was in my babel config (.babelrc). If I changed a component and the style, it would reload, but a style change alone would not. The Usage instructions say to do this... I thought I had already done that step, but may have undone it accidentally. |
Thanks Tyler ... do you mind posting your babel config file? I'm a n00b at this, thanks for your help! |
For .babelrc, I have: Your config might be somewhere other than .babelrc, i'm not sure, but hopefully adding "styled-jsx/babel" to your array of plugins in your config will do the trick |
@justswim Did the above work for you? I'm having a similar issue, and it didn't work. |
@tylermares @paigecwilley I don't think I understand the .babelrc example. Do I just add a file named .babelrc ? When I create a next.js app, there is no .babelrc file to begin with, so I don't quite understand what it means to make one. I do have a next.config.js file that looks like this:
Can I add something here to solve the problem? |
Although I am not using styled-jsx in the context of next.js, yes I think you should try placing a .babelrc file somewhere in the root of your project if you don't already have one. I noticed on https://github.com/zeit/next.js/ the listing of files on the root of that project does contain a .babelrc (first one after the folders). Though it does not have this plugin added there, it sounds like styled-jsx is an add-on or being used in a limited way, as far as reloading. In debugging this I have noticed different cases, such as style not reloading if the style uses a variable declared outside (a change to it would not refresh the page) -- so it might help to understand the limits of reloading by testing combinations of saving just a style change and/or saving another change to your component, and seeing if the reload detects one or both. I started using styled-jsx only yesterday, so maybe I have had a bit of luck having the correct setup in my project... |
@justswim there was a problem with the styled-jsx. |
still happens in the |
Similar issue with basic-css example |
@arunoda also seeing this on a clean install of latest beta: style jsx updates cause old styles to disappear, but new styles take effect after manual refresh |
We've fixed this issue. |
See this GIF:
http://imgur.com/a/t7nKx
When I'm using styled JSX, it doesn't hot reload in the browser.
When I change styles, they are not hot reloaded correctly.
Steps to repro:
yarn dev
go to localhost:3000
Open up pages/index.js
change a style, for example change color: #333 to color: white
Expected behavior
color of the text changes to white
Actual behavior
styles on the page somehow disappear. A page refresh is required to render the correct styles
Environment
node --version: 7.6.0
npm --version: 5.0.3
Here is a demo repo where this is happening: https://github.com/justswim/nextjs-no-hot-style-reload
Thank you for your help!
The text was updated successfully, but these errors were encountered: