rum 2023-02-28

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')

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

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')

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"))

yup that was it! thanks