Multiple stylesheets in a component #182
-
For typography, I have a defined global stylesheet and a local stylesheet for each component. As shown in the example below, I must utilise both stylesheets in one of the component. I've observed that when the theme is changed, the component would render twice. Is there a different way to use two stylesheets?
|
Beta Was this translation helpful? Give feedback.
Answered by
jpudysz
Apr 11, 2024
Replies: 1 comment 1 reply
-
This is an antipattern: each You don't need a globalStyleSheet. You can:
I would recommend using variants. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sftechswdev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an antipattern: each
useStyles
hook will cause a re-render, which is the reason for the double re-render.You don't need a globalStyleSheet. You can:
BaseText
component that accepts these variants and renders different styles: https://www.unistyl.es/reference/variants/globalStyleSheet
to thetheme
and simply spread (...
) theglobalStyleSheet
into yourcomponentStyleSheet
.I would recommend using variants.