Closed BierDav closed 11 months ago
Why don't you use isServer
?
const isTypography = (v: unknown) =>
!isServer &&
v instanceof HTMLElement &&
v.classList.contains(Typography.toString());
That would make the whole pr useless, because it would lead to hydration errors
The only way we would be able to achieve this is by using a context just for this, but I don't think that is worth the effort. The majority is not using a separate typography because there aren't a lot of use cases where it is the best way to do so. But maybe in future we will get features of solid start that allow us to access the already rendered html more easily.
I reverted your commit (https://github.com/swordev/suid/commit/c62830e8512ace916677ca3541f3196ec67e8f2d) and implemented a more suitable solution (here) compatible with SSR.
This potentially makes old code a bit more inefficent when using typography directly as label, but sadly there is no way of reliably checking what the
isTypography
test for, because we have just access to an html string, which would be even more inefficent to parse it as just wrapping everything in a div.And when someone wants to be as efficent they have to just set the
disableTypography
prop. In my opinion it's a worth tradeoff.