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.

useless className warning

See original GitHub issue

I’m using styled-components to style a rc-tooltip, which takes the property overlayClassName instead of className in order to style the tooltip’s overlay. My code contains a very basic wrapper to map the prop:

const TooltipStyleWrapper = props => {
	const { className, ...rest } = props;
	return <Tooltip overlayClassName={className} {...rest} />;
};

When this component mounts, styled-components issues the className warning:

It looks like you’ve wrapped styled() around your React component (TooltipStyleWrapper), 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.

In truth, I am passing down className, but by a different name. I did a brief search for this issue and saw PR #2156 for adding another prop to suppress this warning.

I don’t think it’s appropriate for styled-components to pry into my components to see how I’m using the provided className, and I really don’t think it’s appropriate that I should have to add another obtuse prop to suppress this warning. The above code already exists as a bridge between sc and rc-tooltip, and I very much don’t want to go to even further lengths to build this bridge. If a warning is going to exist, it should be smart enough only to warn me when something is actually wrong.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Fer0xcommented, Oct 29, 2018

@probablyup sure, will add this today

1reaction
probablyupcommented, Oct 28, 2018

cc @Fer0x - can you add a guard so that each component only emits the warning once? We can do a simple reference equality test using an ES6 Map and set a flag once the warning has gone out once.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Prop `className` did not match. when using styled ...
That error is showing you the class that is being created by your styled-components library on the server and how it is different...
Read more >
Perl pragma to control optional warnings - Perldoc Browser
In the code below, the use of time , length and join can all produce a "Useless use of xxx in void context"...
Read more >
Understanding the React exhaustive-deps linting warning
This happens when a variable in useEffect never updates. Sometimes this is what you want, but most of the time, you don't. Here...
Read more >
List of the armcc error and warning messages - Arm Developer
The ARM Compiler Errors and Warnings Reference Guide provides lists of the errors and warnings ... 21 : type qualifiers are meaningless in...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
This is completely pointless, and requires that the object be garbage ... just access the static methods directly using the class name as...
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