What's wrong with the following?
(def months-name ["Jan"
"Feb"
"Mar"
"Apr"
"May"
"Jun"
"Jul"
"Aug"
"Sep"
"Oct"
"Nov"
"Dec"
])
(defn []
[:div (mapv (fn [x] [:div x ]) months-name)])
Do I need to do the mapv outside of the div and put the result there?
It says invalid arityWhat's invalid about (defn [] ...) ?
I was able to make the for work, but the mapv won't
Why is that?
impossible to comment without seeing what your actual code was
but in general you need to consider what the final result is. so for example with mapv you end up with [:div [[:div "Jan"] [:div "Feb"]] which reagent might not like, the for produces a lazy-seq which reagent probably handles in special ways
I see! Is there a way to make a sequence return as its content?
(into [:div] (mapv ...)) is an option
Great it works, thanks a lot!
The idiom in reagent is usually to write something like this
(def months ["January" "Feburary" "March" "..."])
(defn panel []
(into [:div] (for [month months]
[:div {:key month} month])))
Replacing the divs with an unordered list, we get the following result
you need to share your actual code if you want accurate help. (defn [] ...) is invalid
you could have (mapv (fn [x] ...)) months-name which would give you a invalid arity? ie a misplaced )