Fork me on GitHub
#rum
<
2020-05-27
>
didibus09:05:55

Ok, I realized that :class-properties seem to set like static class level fields, so it'll be shared between multiple instance of a component. For ref that was weird, so this is how to do refs with class based components:

(rum/defcs MyComponent <
  {:will-mount #(-> % (assoc ::some-ref (rum/create-ref)))
   :did-mount
   (fn[state]
     (.scrollIntoView (rum/deref (::some-ref state)))
     state)}
  [state]
  [:div {:ref (::some-ref state)}])

levitanong18:05:55

I think you meant (::some-ref state) 😄 in [:div {:ref (:some-ref)}])

didibus19:05:43

Oh yup, I did. Will fix.