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.

Syntax highlighting not working when using inline function as an argument(`styled(() => <Foo />)`)

See original GitHub issue

To avoid warning “Received true for non-boolean attribute XXX”, I’m passing inline function as an argument to styled function.

const StyledLink = styled(({ primary, ...otherProps }) => <Link {...otherProps} />)`
  /* styles */
` 

This pattern is useful for avoiding some warnings. (see styled-components #1198 and discussion.) However, when applying this pattern, syntax highlighting is not supported.

syntax highlighting not supported in inline function argument

Also, I could assign inline function to variable for syntax highlighting.

const StylableLink = ({ primary, ...otherProps }) => <Link {...otherProps} />
const StyledLink = styled(StylableLink)`
  /* styles */
`
syntax highlighting supported in variable argument

But, doing so is both costly and cumbersome. It would be great if you’ll support syntax highlighting for this.

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
joeytwiddlecommented, Nov 18, 2020

I created a small bounty for this issue (~21 USD). Thanks for the plugin!

Edit: 2020/11/19 the bounty is now showing as 15 USD. Sorry, I’m not sure why it dropped! (If anything, USD has dropped…)

3reactions
adamcbrewercommented, Mar 12, 2020

Have a little workaround:

export const Component = styled((props) => (
  <div {...props} /
))(css`
  color: red;
`)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sphinx inline code highlight - Stack Overflow
syntax_highlight is an ordinary docutils setting, which can be set in docutils.conf . This file is respected by Sphinx too, if placed in...
Read more >
API Reference - styled-components
This is a method that creates a new StyledComponent with a different tag or component applied to it, but all the same rules...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Common Lisp Style Guide - Google
We welcome remarks and constructive feedback on how to improve our guide, and on what alternate styles work for you and why. This...
Read more >
A case against syntax highlighting - Linus Åkesson
If you color some program in random colors, like you did with your Alice In Wonderland text, it REALLY will be hard to...
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