Reputation: 287590
I seen plenty of code like this:
(defn simple-component []
[:div
[:p "I am a component!"]
[:p "This component has two paragraphs"]])
Is there a way to make that component have just two p elements, without the enclosing div?
Upvotes: 3
Views: 166
Reputation: 711
You can do that with a react fragment which can created in two ways:
With a js array (which takes react elements):
(defn simple-component []
#js [(r/as-element [:p "I am a component!"])
(r/as-element [:p "This component has two paragraphs"])])
With the [:<> ... ]
tag (which takes hiccup forms):
(defn simple-component []
[:<>
[:p "I am a component!"]
[:p "This component has two paragraphs"]])
Upvotes: 1
Reputation: 433
it seems "rookie mistake". please check this wiki page: Form-1: A Simple Function https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components
Upvotes: 1