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.

Do not pass suppressClassNameWarning to wrapped components

See original GitHub issue

Environment

System:

  • OS: macOS 10.14
  • CPU: (4) x64 Intel® Core™ i5-7267U CPU @ 3.10GHz
  • Memory: 75.45 MB / 8.00 GB
  • Shell: 3.2.57 - /bin/bash

Binaries:

  • Node: 8.15.0 - /usr/local/opt/node@8/bin/node
  • npm: 6.4.1 - /usr/local/opt/node@8/bin/npm

npmPackages:

  • babel-plugin-styled-components: ^1.10.0 => 1.10.0
  • styled-components: ^4.1.3 => 4.1.3

Summary

  • suppressClassNameWarning produces React warning suppressClassNameWarning should either only be using lowercase letters instead of camelCase, or it should be filtered from being applied to the DOM. Otherwise, React complains.

(see https://github.com/styled-components/styled-components/pull/2156/files/fe66a4f9aae8f4736c8c6bc08df64e56d892844d)

Reproduction

Steps to reproduce

  • add suppressClassNameWarning as a property or attribute

Expected Behavior

  • styled-components warning is suppressed

Actual Behavior

  • styled-components warning is suppressed but then React gives warning:

Warning: React does not recognize the suppressClassNameWarning prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase suppressclassnamewarning instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Jan 31, 2019

I lightly suggest in https://github.com/styled-components/styled-components/blob/fe66a4f9aae8f4736c8c6bc08df64e56d892844d/src/utils/classNameUseCheckInjector.js

Change from:

 if (
      (target.props && target.props.suppressClassNameWarning) ||
      (target.attrs && target.attrs.suppressClassNameWarning)
    ) {
      return;
    }

Change to:

 if (target.props && target.props.suppressClassNameWarning)
    {
      delete  target.props.suppressClassNameWarning;
      return;
    }
 if (target.attrs && target.attrs.suppressClassNameWarning) {
      delete target.attrs.suppressClassNameWarning;
      return;
    }
1reaction
tanebacommented, Jan 31, 2019

Aha, understood! Can I address this issue? If so, I will send PR later! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

styled-components is saying wrapped styled() around your ...
It looks like you've wrapped styled() around your React component (Component), but the className prop is not being passed down to a child....
Read more >
Releases - styled-components
Updating styled components is usually as simple as npm install . ... Filter suppressClassNameWarning to not to pass down to the wrapped components...
Read more >
styled-components | Yarn - Package Manager
Interpolating a styled component into a string now returns the static component selector (emotion cross-compat) · Add suppressClassNameWarning prop to disable ...
Read more >
Higher-Order Components - React
While the convention for higher-order components is to pass through all props to the wrapped component, this does not work for refs. That's...
Read more >
styled components suppressClassNameWarning
CodeSandbox is an online editor tailored for web applications. ... styled components suppressClassNameWarning. 0. Embed Fork Create Sandbox Sign 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