Fork me on GitHub
#fulcro
<
2022-09-16
>
Ernesto Garcia11:09:17

I'm have a loading marker that works when the page is already rendered, but it doesn't work the first time, when the page first loads. Any idea of why that might be? I am running in a detached subtree with hooks/use-root .

Ernesto Garcia11:09:29

I have the following components:

(fulcro-comp/defsc ForecastRow [_this _props]
  {:query [:forecast/id :forecast/name]
   :ident :forecast/id})

(fulcro-comp/defsc ForecastList [_this {:keys [forecasts-data] :as props}]
  {:query [{:forecasts-data (fulcro-comp/query ForecastRow)}
           [fulcro-fetch/marker-table 'ForecastList]]
   :initial-state {:forecasts-data []}}
Hook:
(let [forecasts-data (fulcro-hooks/use-root fulcro/app :root/forecasts ForecastList {})]
    (fulcro-comp/with-parent-context fulcro/app
      (ui-forecast-list forecasts-data))
Loading:
(fulcro-fetch/load! fulcro/app :forecasts ForecastRow
     {:target [:root/forecasts :forecasts-data]
      :marker 'ForecastList})

Ernesto Garcia11:09:23

The first time the page loads, I am always receiving forecasts-data = nil, until the data is loaded. But then, if I do a reload, I do get the marker updates in forecasts-data.

Ernesto Garcia15:09:31

This is strange. I need to initialize the root-key prior to the first load!, for marker updates to work.

(swap! (::fulcro-app/state-atom fulcro/app)
      assoc :root/forecasts {})

Ernesto Garcia15:09:31

It does work when using use-component (with a constant ident) instead of use-root. use-root doesn't seem to start refreshing changes until its root-key is populated.

Ernesto Garcia15:09:48

Could this be related to what I experienced of Dynamic Routing not working on use-root, but working on use-component?

tony.kay17:09:04

General hooks support is newer and not as well-tested than the traditional Fulcro composition techniques. I still recommend using the older mechanisms as the primary composition technique, and reserve the use of hooks for cases where dynamism is actually needed.

tony.kay17:09:28

I use use-component way more than use-root

tony.kay17:09:17

The dynamic routing system is designed to use the queries (from the real mounted app root, often) for various features. I guarantee use-root and dynamic routers will not be 100% compatible.

tony.kay17:09:32

In terms of refresh of load marker: probably a bug. Im’ sure the load marker is going into state via load. Not sure why you’re getting a missed refresh on startup.

Ernesto Garcia14:09:12

Thanks @U0CKQ19AQ. I'm not using detached roots as a way to structure the application, but as a means to progressively introduce Fulcro in an existing application.

tony.kay14:09:47

Ah I see. Well I'm open to prs if you find an issue, or an issue with a simple reproducible problem. Eg make a repo with small example of problem that I can run and fix.

👍 1
gratitude-thank-you 1
janezj11:09:29

I would like to be able to refine report controls with more attributes. for example type="numeric" and others from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number So I should probably modify com.fulcrologic.rad.rendering.semantic-ui.controls.text-input and define attributes on control? ro/controls { ::xyz {:type :string :label "xyz" :attributes {:type "numeric"}}} (dom/input (*merge* *`attributes`* {:readOnly (boolean disabled?) :placeholder (str placeholder) :onChange chg! :onBlur (partial run! false) :onKeyDown (fn [evt] (when (evt/enter? evt) (run! true evt))) :value (str value)}))

zhuxun213:09:29

Does :pre-merge work with :use-hooks? true?

zhuxun213:09:57

I can't figure out why my :pre-merge fn is never called

roklenarcic14:09:04

Does anyone know what to change in Semantic UI classes so we get form buttons working on mobile? Notice that the buttons get overlaid by the form pane

Ernesto Garcia15:09:31

This is strange. I need to initialize the root-key prior to the first load!, for marker updates to work.

(swap! (::fulcro-app/state-atom fulcro/app)
      assoc :root/forecasts {})

Ernesto Garcia15:09:31

It does work when using use-component (with a constant ident) instead of use-root. use-root doesn't seem to start refreshing changes until its root-key is populated.