antizer icon indicating copy to clipboard operation
antizer copied to clipboard

Question regarding adapt-class implementation

Open tacticiankerala opened this issue 6 years ago • 0 comments

I was trying to get the following snippet to work in RUM,

(def menu-items [{:key "home"
                  :title "Home"
                  :icon "smile"}
                 {:key "about-us"
                  :title "About Us"
                  :icon "smile"}])

(defn menu []
  (ant/menu
   {:theme "dark" :mode "inline" }
   (for [{key :key title :title icon :icon} menu-items]
     (ant/menu-item
      {:key key}
      (ant/icon {:type icon})
      [:span.nav-text title]))))

But, it was not showing up. Digged a bit into the implementation of adapt-class and found this,

...
type# (first children)

new-children (if (sequential? type#)
                       [(sablono.interpreter/interpret children)]
                       children)

vector->react-elems (fn [[key val]]
                              (if (sequential? val)
                                [key (sablono.interpreter/interpret val)]
                                [key val]))
...

So, I went ahead changed that to the following and everything started working fine(at least for me 😄 )

...
new-children (sablono.interpreter/interpret children) 

vector->react-elems (fn [[key val]]
                                      [key (sablono.interpreter/interpret val)])
...

I think sablono already handles all the cases were input being vector, seq, object etc.. So, this is sufficient for the functionality right?

tacticiankerala avatar Sep 26 '18 20:09 tacticiankerala