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.

When passing a component as a function, the css markup stops working.

See original GitHub issue

There are certain edge-cases where you must selectively pass props to the component you are styling. This happens, when you are using third party components, that freely forward everything to the dom. So in this case you cannot pass any prop you want to the component, as that results in an error. The issue can be seen discussed here: https://github.com/styled-components/styled-components/issues/135#issuecomment-256018643 https://github.com/couds/react-bulma-components/issues/187

The solution is as such: const ListElement = styled(({ active, ...rest }) => <Link {...rest} />)

However this makes the markup not work.

Steps to reproduce: Create a styled component const, and use the above code, see, the markup highlighting not work anymore.

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:5

github_iconTop GitHub Comments

4reactions
jasonwilliamscommented, May 10, 2021

Fixed in v1.6.0

3reactions
XYShaoKangcommented, Oct 7, 2019

temporary solution, installation vscode-language-babel then add before the template string /* CSS */

const SearchWarp = styled(({ children, searchDisplay, ...otherProps }) => (
  <SearchBox pose={searchDisplay ? `show` : `hide`} {...otherProps}>
    {children}
  </SearchBox>
))/* CSS */ `
  display: block;
  padding: 6px;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  border-top: 1px solid rgba(0, 0, 0, 0.07);
`

2019-10-07_10-10-54

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complete list of reasons why a css file might not be working
It showed the error: I/O Error: Unknown mime type : text/plain;charset=UTF-8 . It appears both PHP function ( mime_content_type ) and 'file -bi'...
Read more >
Handling common HTML and CSS problems - MDN Web Docs
Some problems can be solved by just taking advantage of the natural way in which HTML/CSS work. Unrecognized HTML elements are treated by...
Read more >
Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >
Not able to import CSS in LWC No MODULE named markup
Indeed, there seem to be a bug with Summer 20 release, when sharing a common CSS file with import function into another LWC...
Read more >
How and when to force a React component to re-render
Since the beginning of the web, we've used HTML and CSS to define ... We do this by building components and working with...
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