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.

Classname warning appears because loadable loading component doesn't attach it

See original GitHub issue

When you try to style a HOC [like react-loadable] you will get a console.warn, that the className is not being passed down, even if it is.

Reproduction

https://codesandbox.io/s/pyx951r0rj

Steps to reproduce

Open the console.

Expected Behavior

No console.warn

Actual Behavior

There is this console.warn It looks like you've wrapped styled() around your React component (LoadableComponent), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

31reactions
martonlangacommented, Feb 9, 2019

For the folks using Next.js, don’t forget to add this .babelrc config to your project.

13reactions
probablyupcommented, Oct 21, 2018

styled(SomeComponent) is not an unrecommended pattern. It’s a core use case in fact.

On Sun, Oct 21, 2018, 3:20 PM Phil Plückthun notifications@github.com wrote:

I’m not sure this is worth addressing:

  • styled(SomeComponent) is not recommended
  • The warning is technically correct; the className is indeed not applied
  • Loadable -> StyledComponent -> ActualLoadedComponent would do the trick even

So I’m not sure whether we should spend the added time on improving its accuracy 😕

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/styled-components/styled-components/issues/2126#issuecomment-431700728, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiy1qRxHijMegqEEZ_zZ3c-FjVu0aKXks5unNccgaJpZM4Xv0lN .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Prop `className` did not match. when using styled ...
It looks like the className prop that is being set on your component is not the same when the component is rendered on...
Read more >
Using React Loadable for Code Splitting by Components and ...
Code splitting is a technique where an application only loads the code it needs at the moment, and nothing more. For example, when...
Read more >
FAQs - styled-components
The warning message below indicates that non-standard attributes are being attached to HTML DOM elements such as <div> or <a>. If you are...
Read more >
Best practices for React iframes - LogRocket Blog
Explore two use cases for React iframes, embedding external content in a web application and isolating certain parts of an app.
Read more >
Docs • Svelte
If you export a const , class or function , it is readonly from outside the component. Functions are valid prop values, however,...
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