Typescript complains when the css prop is passed back into the css prop using array composition
See original GitHub issueI’m attempting to compose styles so that any css prop styles passed into my component are merged back into the inner styles (and take precedence)
The problem is that the TS compiler complains when i attempt to pipe the the received css prop back into the prop.
For example:
export type PProps = React.HTMLAttributes<HTMLParagraphElement>
export const P = (props: PProps) => (
<p
css={theme => [css`font-family: ${theme.font.secondary};`, props.css]} // <-- typescript complains
{...props}
/>
)
Is this expected / or is there a better way to achieve this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to use styled-component CSS props with Typescript
As far as I understand your code, you don't need to use any libraries. Here is the working example, where colors in the...
Read more >TS Playground - An online editor for exploring TypeScript and ...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Read more >Minimal TypeScript Crash Course For React
This page aims at getting you up to speed quickly without overwhelming you with all the details. You'll get a rather minimal introduction...
Read more >Generically Typed Vue Components with Composition API
In a nutshell, we need a way to pass down the generic type information and replace the value prop type with it.
Read more >React hooks (v17.0.3) and Redux handbook using TypeScript ...
render props: Passing functions down the component hierarchy as via ... At a high level there are 2 strategies to consider when using...
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
Sure! here you go: https://codesandbox.io/s/strange-wiles-ljk3s
Could you prepare a runnable repro case so I could take a look?