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.

V4: classes not properly forwarded in some cases

See original GitHub issue

Environment

System:

  • OS: macOS High Sierra 10.13.6
  • CPU: x64 Intel® Core™ i7-6920HQ CPU @ 2.90GHz
  • Memory: 459.63 MB / 16.00 GB
  • Shell: 3.2.57 - /bin/bash

Binaries:

  • Node: 8.12.0 - /usr/local/bin/node
  • Yarn: 1.10.1 - /usr/local/bin/yarn
  • npm: 6.4.1 - /usr/local/bin/npm
  • Watchman: 4.7.0 - /usr/local/bin/watchman

npmPackages:

  • babel-plugin-styled-components: ^1.8.0 => 1.8.0
  • styled-components: ^3.4.9 => 3.4.10

Reproduction

https://codesandbox.io/s/w32730pr5

Steps to reproduce

Try to extend the styles of a button from semantic-ui-react:

import { Button as SemanticBtn } from "semantic-ui-react";
import styled from "styled-components"; // latest v4

import "semantic-ui-css/semantic.min.css";

const Button = styled(SemanticBtn)`
  &&& {
    background: green;
  }
`;

// inside render:
<Button primary>test </Button> // this gets the updated styles with semantic-ui styles properly
<Button as="a" primary> // this fails to have semantic-ui styles because the class does not get forwarded

Expected Behavior

The second button should render as an anchor with the classes forwarded so that it is still styled properly like a button (Notice the expected “ui primary button” classes) <a class="ui primary button sc-bdVaJa kmcmFQ" />

image

Here is an example running styled-components v3.4.10 where this was previously working https://codesandbox.io/s/62l6z2j02z

Actual Behavior

Notice that the second button renders like this (button classes not forwarded): <a class="sc-bZQynM bMlcym">test </a>

So it ends up losing some styles and does not render like a button

image

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
probablyupcommented, Oct 22, 2018

Are you saying that in v4 styled-components has its own handler for the as prop and that it is conflicting with semantic’s (hence why it breaks)?

Exactly. But we will have a way around this soon.

0reactions
kusmierzcommented, Feb 27, 2019

Hey @probablyup, have you time to look at this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forward Declaration of a Base Class - c++ - Stack Overflow
A base class MUST be declared (not forward declared) when being declared as a based class of another class. An object member MUST...
Read more >
RFC 7239: Forwarded HTTP Extension
Such conclusions are not possible to make with the X-Forwarded class of header fields. The header field defined in this document is optional...
Read more >
Implement Quality of Service Policies with Differentiated ...
This document describes how to set the Differentiated Services Code Point (DSCP) values in Quality of Service (QoS) configurations on a ...
Read more >
Rule 23. Class Actions | Federal Rules of Civil Procedure
(a) Prerequisites. One or more members of a class may sue or be sued as representative parties on behalf of all members only...
Read more >
Chapter 8. Classes - Oracle Help Center
Class declarations define new reference types and describe how they are implemented (§8.1). A top level class is a class that is not...
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