Turn hiccup into html in a reagent application

761 views Asked by At

This might sound a stupid question, but how do I turn a piece of hiccup into html in a ClojureScript reagent application?

I want something like this :

(html [:div [:p "hello world" ]])

that produces

<div><p>hello world</p></div>

This is what you can do in hiccup.core, but as far as I can see, that's in Clojure. Not ClojureScript in the browser.

OTOH, ClojureScript / Reagent clearly knows how to do it in the browser. It's doing it all the time. But I can't actually find a library call anywhere in reagent where I can do this explicitly, outside the reagent rendering process.

1

There are 1 answers

1
Alan Thompson On BEST ANSWER

I'm not sure why you would want to do this, but it appears one answer is to use the function:

Normally, your Reagent components only return Hiccup data, and you let reagent.dom/render do all the hard work of reactively "rendering" only the changed components into the DOM.


P.S. When in doubt, you can often find documentation at cljdoc.org. Most Clojure projects have a direct link there from their GitHub page (Reagent does, for example). Or, you can go to cljdoc.org directly and search there.