Styled-components break with react-router v4
See original GitHub issueTrying to make use of a styled-component with react-router v4 breaks with the following error
StyledComponent.js:71 Uncaught TypeError: subscribe is not a function
componentWillMount @ StyledComponent.js:71
Confirmed that this isn’t an issue with react-router because This works
const Li = props => <li style={{display: "inline-block"}} {...props}/>
But this fails and throws the above error when used with react-router v4
const Li = styled.li`
display: inline-block`
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
How to style React Router links with styled-components
Adding and styling navbar links using styled-components ... Inside our src folder, create a folder called styles and a file named NavStyle ....
Read more >How to style your React-Router links using styled-components
METHOD-3: Styling React-Router links using 'NavLinks' and 'activeClassNames'. activeClassName is an attribute that we can use to create a class ...
Read more >React-Router not correctly rendering Styled-Components Styles
Here is my code for the specific styled component. import Styled from 'styled-components'; const Title = Styled.
Read more >Using styled-components with react-router · Issue #184 - GitHub
It breaks the whole premise of styled-components , I feel like there has to be a better escape hatch for the above case?...
Read more >Releases - styled-components
Updating styled components is usually as simple as npm install . Only major versions have the potential to introduce breaking changes (noted in...
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
I think this may be because
react-router
also uses broadcasts via react-broadcast and there is a clash as both putbroadcasts
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.Released as
1.0.4
– thanks for reporting and testing this everyone!