gravity-ui / uikit

https://gravity-ui.com
MIT License
516 stars 84 forks source link

Coercion to use ThemeProvider #1632

Closed Fettser closed 3 weeks ago

Fettser commented 3 weeks ago

The documentation suggests using two different approaches to provide theme: CSS classes and ThemeProvider. My project based on SSR, therefore I prefer to use CSS classes (ThemeProvider uses useLayoutEffect inside, that works incorrectly with SSR). In the 5-th version CSS classes works, in the 6-th you must use ThemeProvider (some components depend on ThemeContext). When the library allows two methods, it seems like a bug. For example: photo_2024-06-07_15-09-49

amje commented 3 weeks ago

@Fettser It's not a bug, since v6 wrapping your App inside the ThemeProvider is mandatory. I've fixed the docs in #1633

Fettser commented 3 weeks ago

@amje, I think the ability to use ThemeProvider with SSR needs to be added (for example, use safe useLayoutEffect)