Comments (12)
I think this may be because react-router
also uses broadcasts via react-broadcast and there is a clash as both put broadcasts
onto the context. I think the fix above is just papering over the cracks.
Maybe it would be better to remove the broadcast stuff in this module and depend on react-broadcast
instead? The code is very similar and there would be no overwriting happening on the context.
from styled-components.
I got the same error.
I found this issue happened StyledComponent.js#L44, it can get the this.context
but didn't have __styled-components__
, I try to fixed this line become
const subscribe = this.context.broadcasts[CHANNEL]
this.unsubscribe = subscribe && subscribe(theme => {
// This will be called once immediately
this.setState({ theme })
})
it works fine
from styled-components.
Interesting, @madeinfree would you mind submitting a PR with this change? Then I can take a look if that fixes the issue once and for all! Thanks!
from styled-components.
@mxstbr no problem ~
from styled-components.
I think this may be because react-router also uses broadcasts via react-broadcast and there is a clash as both put broadcasts onto the context. I think the fix above is just papering over the cracks.
Interesting theory. We could just not use the broadcast
context property and use theme
instead?
Maybe it would be better to remove the broadcast stuff in this module and depend on react-broadcast instead? The code is very similar and there would be no overwriting happening on the context.
The reason we don't do this (if you look at the PR I actually initially built it this way: #56) is that it would mean that every styled component is wrapped in two components instead of one, which has a non-negligible performance impact. I thought I integrated it properly so it doesn't matter if there's another broadcast happening, but obviously I was wrong.
from styled-components.
I'm getting the same error with react-router v4, i think i'm goin to use @madeinfree fix for now
from styled-components.
Can replicate – working on a fix now! 🔥
from styled-components.
Could you try out #86 in your project and report back if it fixes the issue? It did for me in a simple test, but I want to make 100% sure!
from styled-components.
I can try ~~ 👍🏻
from styled-components.
Just tested the PR #86 . Issue resolved. 👍
from styled-components.
Awesomeee, thanks!
from styled-components.
Released as 1.0.4
– thanks for reporting and testing this everyone!
from styled-components.
Related Issues (20)
- Failed to parse `&` multiple times in `:is() :where() :has()` pseudo-class selector
- Theme prop (not styled) is not being passed through HOT 1
- Feature request for v5 to ease migration to v6 of large ecosystems
- Interplay of `shouldForwardProp` clarifying question
- Export the `toStyleSheet` function HOT 3
- createGlobalStyle not working version >= 5.3.1 HOT 1
- [Docs] Lint for pseudo selectors - Styled Components update from v5 to v6 HOT 1
- Tailwind selectors do not work the expected (from me) way
- React SSR Streaming Bug
- Error while building project after upgrading from 5.3.11 to 6.0.0 HOT 2
- styled-components is ~50% larger than it could be due to IE11 support HOT 1
- Cannot infer the 'as' and 'forwardedAs' props by React.ComponentProps
- Ssr not picking up styled components from an npm package HOT 1
- error TS4023 when compiling a library that uses "styled-components": "^6.1.9" HOT 4
- Required attrs type fixes for 6.1.9 not applied when using prop factory
- Types of `.attrs` are still broken for React Native on 6.1.9 when using `styled()` HOT 2
- Required attrs type fixes for 6.1.9 not applied when using union props HOT 1
- Heap issues in latest 6.1.9 HOT 3
- Regression: `typeof` on a styled component returns incompatible type HOT 1
- toHaveStyleRule assertion fails after upgrading to 6.1.10 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styled-components.