Fork me on GitHub
#shadow-cljs
<
2024-04-26
>
danielneal13:04:50

Is there a way of using a different naming scheme for classes in shadow-cljs. Because I have a cljc file, I think the class names are different for clojure and clojurescript, which means (I think) that when I try to hydrate something server-side rendered, it barfs. Thoughts?

thheller14:04:01

there is not no. although I do not understand this error? I mean isn't the point of hydration to use the same code?

thheller14:04:58

I mean what you can do is pull the css defition "up" into a let or def, so (def $the-class (css ...)) and in both spots use $the-class instead of (css ..) forms?

danielneal14:04:14

I was thinking it’s because it’s a cljc file so when I generate the markup in clojure on the server and on the client the class names don’t match because there are conditional cljs lines (e.g. cljs only library requires) , which makes the line number different between both… but I’m not 100% sure that’s it

thheller15:04:05

no, the classname is generated off the exact location in the source code

thheller15:04:21

so its just the namespace plus line and colum

thheller15:04:42

so the above are just two different css uses

thheller15:04:04

cljc preserves the location info, so that doesn't change regardless of which branch you are in

danielneal15:04:05

ah ok, maybe something got stale, thanks!

danielneal15:04:16

Getting this hydration working with SSR without errors is proving difficult

thheller15:04:44

I think hydration is nonsense, so I never tried to actually use it

danielneal16:04:43

what do you do instead? do you do everything on the client?

thheller16:04:00

no, mix of everything. I wrote an entire blog series about it https://code.thheller.com/

thheller16:04:11

The Lost Arts of CLJS Frontend and so on

danielneal18:04:21

oh yes, I forgot about that. Maybe it's time for me to go all in on the thomas heller approach