support remove styles of `injectGlobal`
See original GitHub issueThe problem
I am using emotion in sevelte components, where I can’t use @emotion/react
, and instead I could use @emotion/css
.
I want to inject some global styles when component mount and remove them when component unmount. With injectGlobal
I have no way to undo the injection.
Proposed solution
Alternative solutions
Additional context
- @emotion/css: 11.0.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to update or remove global styles in Emotion
Learn how to change globally injected styles in Emotion without breaking the rest of your app's styles.
Read more >FAQs - styled-components
When using global styling APIs like createGlobalStyle or the former injectGlobal, adding and removing certain styles from the DOM like @font-face definitions ...
Read more >Angular - How to remove <style> element from <head> after ...
So the service should compile sass files and inject global styles? – Hrvoje Golcic. May 13, 2018 at 13:39. No, ...
Read more >Migrating to Recipe 10
In order to support the full set of CSS selectors with emotion, the Recipe ... First, find instance of injectGlobal in your app,...
Read more >styled-components | Yarn - Package Manager
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress. react, css, css-in-js,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is an interesting use case but it’s also quite problematic to handle right now and supporting this out of the box in the current
injectGlobal
could have been a breaking change.You can implement your own version of
injectGlobal
under 20 LOC that would support this:You can check out the demo here. It’s using React for rendering as that was just convenient for me but doesn’t use any React-specific APIs for styling.
@Andarist Interesting. Ok, thanks for that, and the quick response. Removal of rules has been on the back of my mind for large portal systems which load many apps as the user is using it, but maybe it’s not necessary after all.
Best, Greg