rum

coetry 2023-02-28T21:03:36.383749Z

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 K 2023-02-28T22:08:05.904249Z

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

coetry 2023-02-28T22:10:14.687449Z

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 K 2023-02-28T22:15:32.048869Z

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

coetry 2023-02-28T22:16:22.144749Z

yup that was it! thanks