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.

Recursive `styled` components lose `ThemeKey` generic

See original GitHub issue

I am unsure how I would expect it to work, but may make sense to somehow prevent with types or mention this incompatibility.

I created a simple Divider, which works as expected, but gives a typescript error when trying to use it with a different variant.

import { styled, View } from 'dripsy';

export const Divider = styled(View, {
  themeKey: 'divider',
  defaultVariant: 'horizontal',
})({
  bg: '$divider',
});

Related theme variant:

  divider: {
    horizontal: {
      height: 'divider',
      width: '100%',
    },
    vertical: {
      width: 'divider',
      height: '100%',
    },
  },

image Importing View from react-native when creating Divider solves this problem completely and has no issues.

I have no issues with this, just figured I would let you know so we can avoid other users potentially having the same issue 😃

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nandorojocommented, Nov 14, 2021

Oh, I misunderstood. I see now. It must be because we’re clashing generics between views. Good catch. I’ll have to see if we can work around this (perhaps by omitting the previous one)

0reactions
nandorojocommented, Nov 15, 2021

Yeah go for it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to type a styled component without losing any prop with ...
It could be solved as @Huy-Nguyen said but in practice, you lose properties on Styled Components or you have to define the same...
Read more >
Demystifying styled-components - Josh W Comeau
We inject a new CSS class into the page, using that hashed string as its name, and containing all of the CSS declarations...
Read more >
Advanced Usage - styled-components
This component provides a theme to all React components underneath itself via the context API. In the render tree all styled-components will have...
Read more >
How to use SVG in React? The styled components way.
Become a wizard to transform the cloud into a styled component? ... idea to have some kind of generic component for all icons...
Read more >
React Treeview Recursive Styled Components - StackBlitz
Starter project for React apps that exports to the create-react-app CLI.
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