reagent

liebs 2023-10-23T16:51:01.915629Z

I'm not understanding how to use forwardRef correctly. I have a modal that is wrapped in a forward ref like so:

(def modal
  (forwardRef
    (fn [props ref]
      [modal-panel]...)))  ;; <- from 
but I get an invalid hiccup tag as a result:
Uncaught Error: Assert failed: Invalid Hiccup form: [#js {"$$typeof" #object[Symbol(react.forward_ref)], :render #object[Function]} {:showing? #object[reagent.ratom.RAtom {:val true}]} nil]
 (in re_com.box.v_box)
(valid-tag? tag)
    at Object.reagent$impl$template$vec_to_elem [as vec_to_elem] (template.cljs:280:5)
    at Object.reagent$impl$template$as_element [as as_element] (template.cljs:297:22)
    at Object.reagent$impl$protocols$Compiler$as_element$arity$2 (template.cljs:318:10)
    at Object.reagent$impl$protocols$as_element [as as_element] (protocols.cljs:6:16)
    at template.cljs:139:37
    at core.cljs:5704:36
    at core.cljs:5704:35
    at Object.cljs$core$IKVReduce$_kv_reduce$arity$3 (core.cljs:5708:24)
    at Object.cljs$core$_kv_reduce [as _kv_reduce] (core.cljs:715:16)
    at Object.cljs$core$reduce_kv [as reduce_kv] (core.cljs:2596:8)
Do I need to use adapt-react-class or something?

p-himik 2023-10-23T17:02:22.595339Z

Yes, since forwardRef returns a React component. And that [modal-panel] probably also needs to be wrapped in r/as-element.

liebs 2023-10-23T17:06:38.655929Z

I wish I had happened to navigate to that example instead of this one https://github.com/reagent-project/reagent/blob/master/examples/react-mde/src/example/core.cljs

liebs 2023-10-23T17:06:44.428749Z

got it working, though, thanks!

👍 1
2023-10-23T19:52:24.215669Z

is anyone else using clojure-lsp with reagent successfully? It seems like it cant resolve macros like r/with-let (I think because of the clj and cljs version fo reagent.core perhaps?)