Generic parameters not persisted through styled components
See original GitHub issueCurrent behavior:
TypeScript generic parameters are not accessible through the styled
wrapper.
To reproduce:
CodeSandbox example: https://codesandbox.io/s/sad-easley-bw821
- have a generic component with generic props
- wrap as a
styled
component - generic parameter not accessible on the wrapped component
Expected behavior:
Generic parameter is accessible on the resulting HoC. Alternatively, I’m OK with using a type assertion here – I’m just not quite sure what I should be asserting as.
Environment information:
react
version: 16.8@emotion/react
version: 10.0@emotion/styled
version: 10.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to make Styled components generic to receive parameters?
I'm trying to use Styled Components with React FC. I want to display few details inside a div container, which all has the...
Read more >Component prop types are not inferred when using styled ...
Component prop types are not inferred when using styled-components and TypeScript generic parameters. Expect to see someProp, instead no props are shown.
Read more >Styled Components - Gatsby
In this guide, you will learn how to set up a site with the CSS-in-JS library Styled Components. Styled Components lets you use...
Read more >Theming and Theme Switching with React and styled ...
Let's set up a project with React and styled-components. ... to a database so we can persist all the themes along with the...
Read more >ASP.NET Core Blazor CSS isolation - Microsoft Learn
In the following example, the style is not applied to the child component. Pages/Parent.razor : razor. Copy.
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 FreeTop 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
Top GitHub Comments
@tills13 you can extend your assertion with
ComponentSelector
: https://codesandbox.io/s/objective-mclaren-zv8cb?file=/src/App.tsx@Andarist this works for my use case. Thanks for the replies.