Reagent Compiler object is a new way to configure how Reagent turns the Hiccup-style markup into React components and elements.
As a first step, this can be used to turn on option to create
functional components when a function is referred in a Hiccup vector:
[component-fn parameters]
.
(def functional-compiler (r/create-compiler {:functional-components? true}))
;; Using the option
(r/render [main] div functional-compiler)
(r/as-element [main] functional-compiler)
;; Setting compiler as the default
(r/set-default-compiler! functional-compiler)
Now that this mechanism to control how Reagent compiles Hiccup-style markup to React calls is in place, it will be probably used later to control some other things also:
From Clojurist Together announcenment:
As this [hooks] affects how Reagent turns Hiccup to React elements and components, I have some ideas on allowing users configure the Reagent Hiccup compiler, similar to what Hicada does. This would also allow introducing optional features which would break existing Reagent code, by making users opt-in to these. One case would be to make React component interop simpler.
Some ideas:
Open questions:
as-element
with their own Compiler to ensure compatibility.Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close