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

See original GitHub issue

I was trying to adopt WMR in a personal project but kept running into issues. I’ve found that it has something to do with styled-components, but I’m not sure what’s happening.

Error (in browser)

Uncaught SyntaxError: The requested module '/@npm/react-is' does not provide an export named 'typeOf'

Steps to Reproduce

  • Run npm init wmr
  • Run npm i styled-components
  • Import styled-components into the index.js file, import styled from 'styled-components';
  • Run npm start, notice the page does not render and the error in the console

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
developitcommented, Jan 6, 2021

Alright, I finally chased this one down. It’s a bug in styled-components, which uses a fairly old version of Rollup’s commonjs plugin to generate its ESM bundles that is just producing a nonsensical import:

import { typeOf } from 'react-is';  // incorrect, fails everywhere except Webpack

They’d originally told folks to fix this in their own configurations, but having this be broken by default doesn’t seem adequate. Instead, I’ve submitted a PR that implements the correct import generation in their build setup:

https://github.com/styled-components/styled-components/pull/3367

One thing I did find while digging is that this import was broken in 5.1.0 - styled-components@5.0.1 should work.

1reaction
marvinhagemeistercommented, Sep 16, 2021

@damianobarbati The has fix tag is incorrect, I think we forgot to remove it.

I’ve been working on revamping the npm plugin and on the commonjs handling over the past days and got it to render. There is a bit of remaining work to be done before this can be PR’ed, but it’s progressing well so far.

Screenshot 2021-09-16 at 12 01 39
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending styles with styled-components not working
I'm trying to extend styles for a react component using styled-components but is not working. AFAIK, I'm doing it the right way, ...
Read more >
Why Is styled-components "styled" Wrapper Not Working With ...
To avoid this issue, make sure the React component you're using with the styled() wrapper attaches the passed-in className prop (or style prop, ......
Read more >
FAQs - styled-components
Commonly asked questions about styled-components.
Read more >
Issues · styled-components/styled-components - GitHub
customSyntax for Stylelint v14+ · Can't use <use> element with styled-components · Upgrading react dependency to 18.1 · css animation doesn't work if...
Read more >
How To Use Styled-Components In React - Smashing Magazine
Styled components are independent of each other, and you do not have to ... Let's say you're working on a landing page, and...
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