Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[styled-components] Can't use css prop #27

Closed
phuczeero opened this issue May 16, 2020 · 3 comments
Closed

[styled-components] Can't use css prop #27

phuczeero opened this issue May 16, 2020 · 3 comments

Comments

@phuczeero
Copy link

Currently, I got two issues:

  1. Usage of css prop
  2. Typescript error

Ref: https://styled-components.com/docs/api#css-prop

@Can-Sahin
Copy link
Member

Well how am I supposed to know what causes error with the typescript error explanation. Please share code samples or sample repository then I'll reopen

@Can-Sahin
Copy link
Member

Can-Sahin commented May 16, 2020

It requires babel-plugin which you can have by either ejecting or rewiring CRA. We won't do that because it's an advanced customization. You have to do it yourself

Here is how to do it
DefinitelyTyped/DefinitelyTyped#31245 (comment)

@phuczeero
Copy link
Author

phuczeero commented May 17, 2020

I think if this template support styled-components, it should be reconfigured for css prop feature.
According to my ref link, I could use this way without ejecting:

  • import 'styled-components/macro' in which I use css prop
  • import {} from 'styled-components/cssprop' in src/types/index.ts to solve css prop type error

Update
If I use css prop on primitive elements, like <span>, <div>, it still throws ts error.

Thinh922001 added a commit to Thinh922001/KLTN-HUIT-FE that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants