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.

Styled-components break with react-router v4

See original GitHub issue

Trying 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:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
sheepsteakcommented, Oct 14, 2016

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.

0reactions
mxstbrcommented, Oct 15, 2016

Released as 1.0.4 – thanks for reporting and testing this everyone!

Read more comments on GitHub >

github_iconTop 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 >

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