Fork me on GitHub

Hi, what is the proper way to do hot-reload in fulcro? I use app/mount! in the after-load function, however although the data not change after reload(I can confirm this in fulcro inspector), but the ui looks like lost the data. PS, I fill the data with merge/merge-component! .


@U0NBGRGD6 Have you looked at the sample template repo?


That’s the canonical way to do it with shadow-cljs


@U09FEH8GN hi, thanks. but I think my shadow-cljs configuration is correct, just like, init and after load is set correctly. when I save the code, hot-reload actually happens, the problem is UI component will lose their data. (for example, a list view will become empty). But the data is still their, I can see them in the fulcro inspector.


put a println statement in the render for that component to see what is being called and with which props


@U66G3SGP5 the Root receive an empty {}.


are you doing something strange with your queries


you can get query of Root and run that query on state


(defsc Order [this {:order/keys [id qty price] :as props}]
  {:query [:order/id :order/qty :order/price]
   :ident :order/id}

(def ui-order (comp/factory Order {:keyfn :order/id}))

(defsc Root [this {:keys [orders] :as props}]
  {:query [{:orders (comp/get-query Order)}]
   :ident (fn [_] [:component/id :order-page])}
  (.log js/console props)

(defonce app (app/fulcro-app))

(defn init []
  (app/set-root! app Root {:initialize-state? true})
  (app/mount! app Root "app"))

(defn after-load []
  (app/mount! app Root "app"))
this is my code, I'm thinking am I wrong with the :ident of Root?


yeah I don’t think root has an ident


also if you can imagine what you wrote would mean that [:component/id :order-page] has :orders property


which is probably doesn’t


should the state kept when hot-reload in fulcro?


yes, of course


you are hardly supposed to notice reloads


looks that if Root doesn't have a ident, I can't use something like:

(merge/merge-component! app Root
                          {:orders [{:order/id 1
                                     :order/qty 10
                                     :order/price 100}]})


if I set the data by reset! the atom, the behavior will be correct. but since that is non-normalized data, obvious not the way I should use.


Okay, I think I can narrow the problem to when I run app/mount! , the Root will re-render with empty data.


on youtube look up Tony Kay’s channel


there you have a video tutorial how to set up things


I think I now why, the problem is I shouldn't give ident to Root, that will cause it looks for the deeper sturcture.


Yes, giving Root an ident will break things…I need to add an error for that.


Added in 3.0.11 🙂


@U0CKQ19AQ which case should I considering use a [:component/id :xxx] as an ident?


Any time it is a singleton ui component

Philipp Siegmantel06:11:21

Hello. First of all, sorry if this is an obvious question, I'm just getting started with fulcro. I have an svg piano keyboard component, that needs to color keys based on the state of the application. My intuition is to make every key a component as well and set the fill attribute depending on the state. It would mean having to refactor parts of my application, so I better ask if I am on the right track.


I'm not sure I see why it would need to be a component, wouldn't it just be rendering data passed to it by a parent (piano) renderer? How do keys get modified? Is it just color?


So, I would not refactor unless it turned out to be a React performance problem. Having a component for each key would allow you to ask for a render of just a key, but in this case (a shallow tree of components) should be plenty fast.

Philipp Siegmantel07:11:43

OK, I think I have an idea of how to do it. Thanks for helping.


You can have whole keyboard as 1 component, I don’t see why not


especially if it’s a single SVG


3.0.11 is on clojars. This version has some significant rendering optimizations. It was in RC to make sure it didn’t have regressions on rendering, and seems to be working well. It also includes the long-needed fatal error that prevents the beginner mistake of putting an ident on Root.

parrot 4

Basically the older versions were over-rendering (2x per update)…this new version eliminates that and should double performance…but could cause regressions. But I’m using it in big apps and have seen no problems related to that fix.

📈 6

I’ve also added (but not released) keyframe-render2. It is like keyframe-render, but allows you to specify :only-refresh on transactions to eliminate all internal checks and directly refresh a specific list of idents. This can give you component local state speed for things like input fields, while using keyframe for all other renders so you don’t have to worry about dependent data rendering issues. I’ve found use cases where this really is the best of both worlds: keyframe is usually “fast enough” (and is super simple to understand), but allows you to target optimizations to known hot spots easily.


It will be in 3.0.12


or you can use the latest git commit on develop in deps if you want it now


hi all, could anyone point me to an example project that demonstrates how to use fulcro with a sql db (like postgres)?

davewo19:11:52 is the best I could find after a brief look... most likely it has not been brought forward with fulcro3, but this library and the current fulcro template project ( might be a good starting point


Remember that Fulcro has no opinion on database. The developer’s guides for Fulcro and Pathom both show how to satisfy queries and mutations, which is where you’d put code to read/write any database.


The walkable library will is an example of how one could interface with SQL via Pathom if you want a library to do it for you.


on our last project we r using for db interop and it’s been pretty nice.


tried walkable but the fact that joins are in memory and not at the db level kept us away from it. not sure if that has changed since last time we checked it


@U0J6U23FW walkable's joins are not sql joins. I'm still thinking about instroducing new concepts to walkable to express sql joins. You know, sql joins bring their own complexity like name conflicts and shape of data (with EQL we expect tree-like structures, not two dimensional tables)


problem is that some problems dont allow to have joins do on memory and that was a deal breaker on our team. but i get your point, At the end we went with seql for that reason.


Hi, I build an app from the fulcro 3 template. I am new to semantic ui. How do I go about sizing a textarea differently on browser and mobile?


Is there a way to get my hands on a value that gives me eg. access to the current viewport size that I can use programatically inside a fulcro app?


that’s more of a JS question in general than a fulcro question


i’ve done it in the past, should be easy to find on google


but FYI it’s kind of tricky to get right with react’s render model


probably worth looking up how to do viewport size stuff with react components in general (use local-state and overwrite shouldComponentUpdate)


with fulcro.ui.bootstrap3 I could use (b/col {:xs 12 :sm 6 :md 4}) around the form helper. Is there something similar in sematic ui?


yes semantic ui has a grid layout you can use


you can use it directly with html/css or the react components


both do the same thing


i think you should spend some time reading through the semantic UI docs


they are written pretty well and tell you all the things the framework supports


Thanks for the hint. I propably missed something.