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 not working in IE11

See original GitHub issue

Environment

System:

  • OS: Windows 10
  • CPU: x64 Intel® Core™ i7-7700 CPU @ 3.60GHz
  • Memory: 4.90 GB / 15.94 GB

Binaries:

  • Node: 8.11.3
  • Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
  • npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD

npmPackages:

  • styled-components: ^4.0.3 => 4.0.3

Browser

  • IE 11.345.17134.0

Reproduction

Use styled components, extend components like:

export const Flex = styled.div`
	display: flex;
`;

export const ResponsiveFlex = styled(Flex)`
	@media (max-width: 1024px) {
		flex-direction: column;
	}
`;

Expected Behavior

No errors in IE 11, components are rendered and extended successfully.

Actual Behavior

Error: Cannot create styled-component for component: .Flex

Console stacktrace: image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (10 by maintainers)

github_iconTop GitHub Comments

13reactions
ulichcommented, Nov 22, 2018

We had the same issue in IE11

Cannot create styled-component for component: [object Object].

it turned out that the issue of inheriting styles was the problem:

const DefaultNavbar = styled.nav`
    text-align: center;
`

const ExtendedNavbar = styled(DefaultNavbar)`
    position: fixed;
`

create-react-app (react-scripts 2.0.5) styled-components: 4.1.1

we also polyfill with core-js: 1.2.7

by doing

import 'core-js'

i hope this helps.

edit: Just found out that when importing core-js polyfills at the very start of the app, the issue goes away…

10reactions
dfkadyr1commented, Nov 16, 2018

I have this issue image

Read more comments on GitHub >

github_iconTop Results From Across the Web

styled-components - IE11 support - Invalid characters
I've added import 'core-js'; import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable'; to index. js and ie-11 in package. json in section ...
Read more >
FAQs - styled-components
Commonly asked questions about styled-components.
Read more >
Styled Components and CSS-Vars in IE11 - CodeSandbox
Styled Components and CSS-Vars in IE11 ... Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >
Complete Guide On How To Use Styled-components In React
It's a component that is styled not by using a CSS file, but by using CSS syntax in JavaScript (components to be precise)....
Read more >
How To Use React Styled Components Efficiently - Copycat
But, our styles won't work just yet. We need to replace the button tag with our styled component, ButtonStyles. 1. 2. 3.
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