Fork me on GitHub
#rum
<
2023-02-28
>
coetry21:02:36

Are we unable to server render reactive components from clj? Given the following:

(o/defstyled text-big :p.  ;; using ornament here, just spits out a hiccup style vector
  {:font-size "3rem"})

(rum/defc reactive-big-text < rum/reactive
  [*ref]
  (text-big (rum/react *ref)))
I get a casting error when I try to invoke reactive-big-text in a clj repl
(reactive-big-text "hi")
                             
Execution error (ClassCastException) at sober.ui/fn (REPL:26).
class java.lang.String cannot be cast to class java.util.concurrent.Future (java.lang.String and java.util.concurrent.Future are in module java.base of loader 'bootstrap')

Jan K22:02:05

Use rum/render-html (rum.core/render-html (reactive-big-text "hi"))

coetry22:02:14

tried that, same error

(rum/render-html (reactive-big-text "hi"))

Execution error (ClassCastException) at sober.ui/fn (ui.cljc:26).
class java.lang.String cannot be cast to class java.util.concurrent.Future (java.lang.String and java.util.concurrent.Future are in module java.base of loader 'bootstrap')

Jan K22:02:32

Ah my bad. I think you need to pass an atom or something else derefable if you're going to rum/react to it, so I'd try (reactive-big-text (atom "hi"))

coetry22:02:22

yup that was it! thanks