This has been discussed before in this channel but I just wrote an example of how to sync the route from fulcro routers with a plain text url in case it is helpful to anyone. I'm using the fulcro rad routing new-html5-history which in this case works pretty much as the older html5-history. Example builds on @holyjak essential routing example. https://github.com/holyjak/minimalist-fulcro-template-backendless/pull/4
Cheers! Helpful intro to route->url .
Hello guys, just a quick question. Did you have disadvantages when rendering with reagent or sablono? I am about to start a new app and ideally want to use hiccup, but not if its going to bring me troubles.
thanks tony for the quick answer.
I would nudge you to use the function/macros, because I personally think they are better, but in an objective sense there’s not really a ton of difference that can’t be overridden by personal preference. The objective things are:
• The fulcro macros can, in dev, add source lines to the HTML so you can find the code that emitted them. This is a huge plus in large projects.
• The macros, when used properly, emit low-level js with NO runtime overhead, so they are as fast as you can possibly go.
• There are both functions and macros (seamlessly chosen for you by the compiler). This isn’t an advantage, just a note that you can use the dom elements as values.
• The :classes pseudoprop on DOM function/macros makes composing dynamic classes a little cleaner.
• The :.classname#id support in the macros does the transform at compile time. The syntactic convenience has no cost.
(div :.x {} "Hello")
vs
[:div.x {} "Hello"]
I understand the slight desire to make the DOM look like data…but isn’t code already data in LISPs???and the former in Fulcro results in
<div data-fulcro-source="namespace:44" class="x">Hello</div>
with zero extra runtime overhead, because the translation to js in the macro uses JSObject, which emits the correct compile-time constant for the React.createElement call.In shadow-cljs builds you just include this option to enable the source annotations:
:dev {
:compiler-options {
:external-config {
:fulcro {:html-source-annotations? true}}}}I went to a lot of trouble to make all of that work super well in a first-class sense…Also, the INPUT types in React need special treatment, which hiccup processors probably do in a different way. I assume they will work right, but I have not used them.
(the symptom of a broken React input is that if you try to edit the middle of the value when using it in an async controlled sense will cause cursor jumps)
I am sold. Thanks for this details. Will start with the macros then.
The performance of the dom function/macros in Fulcro is actually pretty much native js performance. You probably won’t have any issue with using hiccup if you really want to, as the performance difference really isn’t significant in most cases.