Adding a bit more detail to the previous answer, the fragment
gets spliced into a surrounding list instead of creating a child element. In this way, it is similar to the unquoted-splicing
operator in Clojure ~@
compared to the regular unquote
operator ~
. An example:
(defn middle-seq [] [ :d :e :f])
(defn middle-seq-frag [] [:<> :d :e :f])
When used to create a Reagent component, we see the difference:
[:a :b :c (middle-seq) :g :h :i] ;=> [:a :b :c [:d :e :f] :g :h :i]
[:a :b :c (middle-seq-frag) :g :h :i] ;=> [:a :b :c :d :e :f :g :h :i]
Otherwise, you would have to restructure the input and use concat
:
(vec
(concat
[:a :b :c]
(middle-seq)
[:g :h :i] )) ;=> [:a :b :c :d :e :f :g :h :i]