Q: Why is emotion necessary with CRA?
See original GitHub issueThe top of the readme there is the following simple way which is absolutely amazing at a first sight.
import tw from 'twin.macro'
const default () => <input tw="border hover:border-black" />
Furthermore, there is also this sentence which would give me the impression that without conditionals I can use macro only.
For features like conditional styling and vanilla css, Twin works with styling libraries like 👩🎤 emotion or 💅 styled-components
Unfortunately, when I try that in a clean CRA project, the output I get is like this and that’s where the magical feeling is kinda lost.
<input css="[object Object]" />
To make that work I have to include this ceremony in each file that needs some styling.
/** @jsx jsx */
import { jsx } from '@emotion/core'
import tw from 'twin.macro'
Is there some better way I am simply not seeing?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Change the things you can: Emotion regulation is more ... - NCBI
Each study and a meta-analysis of the three studies revealed that CRA was associated with less depression for lower-SES but not higher-SES ...
Read more >Why is Emotional Expression Important?
Helps see problems in a new light · Makes decision making and problem solving easier · Gets rid of the power of the...
Read more >Mental functions eligibility - Disability tax credit (DTC)
Detailed eligibility criteria that may qualify you for the DTC in the mental functions category.
Read more >Insomnia and Emotion Regulation: Recent Findings and ...
Additionally empirical evidence suggests that emotional dysregulation plays a crucial role in the onset and maintenance of psychopathological disorders.
Read more >Module not found: Can't resolve '@emotion/react'
After installing the package a restart of npm might be needed. Just stop the server and run npm start . – Drubio. May...
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
Thanks for the recommendation, but I am not a big fan of abstracting every little piece into a separate component. Ultimately, it creates a bigger mess than it solves imo. Of course, it makes sense for some frequently used parts, no argument there.
Consider this example I found somewhere around here. If I would be doing
tw.div
for each one of them then I am kinda losing a big benefit of TW - coming up with clever names for styled pieces of markup. So yea, in cases like that I would rather have two unused imports than bunch of styled components.Maybe it’s even better to have common parts in TW config, I am not that much experienced with TW yet to decide on that.
Feel free to close this unless you want to use this issue to track docs improvement.
I remember hitting this at one stage too. I’ll take a look at what’s possible when I’m working on the macro next 👍