Recursive `styled` components lose `ThemeKey` generic
See original GitHub issueI 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%',
},
},
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:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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)
Yeah go for it!