question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with hot module reloading & createGlobalStyle

See original GitHub issue

System:

  • OS: macOS Sierra 10.12.6
  • CPU: x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz
  • Memory: 105.95 MB / 16.00 GB
  • Shell: 3.2.57 - /bin/bash

Binaries:

  • Node: 10.1.0 - ~/.nvm/versions/node/v10.1.0/bin/node
  • Yarn: 1.6.0 - /usr/local/bin/yarn
  • npm: 6.1.0 - ~/.nvm/versions/node/v10.1.0/bin/npm
  • Watchman: 4.7.0 - /usr/local/bin/watchman

npmPackages:

  • styled-components: ^4.0.0-beta.10 => 4.0.0-beta.10

Hi there, not sure if I would call this a bug but thought it was worth pointing out.

I have started using the createGlobalStyle function in v4, but have run into some issues relating to Hot Module Reloading. Whenever a reload is triggered by something outside the createGlobalStyle function, all of its comprising css rules are lost. Here is a simple project which demonstrates this: https://github.com/frednomoon/styled-hot-reload

It seems from this behaviour that its necessary to reload the module containing the global styles every time the page changes. But, of course, this doesn’t happen unless you actually change something inside that module.

I’m guessing its probably possible to solve this with some additional config in my bundler, but obviously would be great to avoid things like that.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:29 (8 by maintainers)

github_iconTop GitHub Comments

16reactions
3nvicommented, Aug 13, 2019

Yup, can verify that it’s not working in v5.0.0-beta.8.

5reactions
jdahdahcommented, Jul 4, 2019

FYI: while it’s fixed in 4.3.2, it seems to persist in v5.0.0-beta.8 (both in conjunction with GatsbyJS).

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Hot Module Replacement not loading styles
I'm having some issues with HMR where its successfully reloading every time I make changes to either one of my jsx files or...
Read more >
Releases
theme'; type ThemeType = typeof Theme; declare module 'styled-components' ... Fix issue with createGlobalStyle and hot module reload, by @probablyup (see ...
Read more >
https://raw.githubusercontent.com/styled-component...
... macro to customize the styled-components import with `importModuleName` (see ... 2018-09-14 - Fix issue with `createGlobalStyle` and hot module reload, ...
Read more >
Better, faster, more powerful: styled-components v4 / Sudo Null IT ...
New API createGlobalStyle , which is a replacement for the old API injectGlobal with ... it makes it possible to dynamically update and...
Read more >
Fast Refresh
Compile Errors; GraphQL Errors; Runtime Errors; getServerData Error. Limitations; Tips. React Hooks. Fast Refresh is an implementation of Hot Reloading with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found