Fork me on GitHub
#fulcro
<
2021-02-26
>
Jakub Holý (HolyJak)10:02:48

New version of https://github.com/holyjak/fulcro-troubleshooting that gets rid of most of the annoying"ident is nil" warnings where they did not had any value.

Casey13:02:00

I'm working through some fulcro concepts with the template and the book. I'm got a component that uses :will-enter that loads data inside dr/route-deferred. It's all working fine. This component is part of the TopRouter that comes with fulcro template. But now I want to add html5 path and history support. I started by just trying to get a different route to load at app boot, not even messing with history or anything yet. After the uism/begin! but before the app/mount! I've added (dr/change-route! SPA ["quiz-index"]). I'd expect the app to boot and the my-route to be rendered. But it is not. I can see that the :will-enter function is firing, the data is loaded from pathom, but the route doesn't render and I get this error

ERROR [com.fulcrologic.fulcro.routing.dynamic-routing:188] -  dr/target-ready! was called but there was no router waiting for the target listed:  [:component/id :quiz-index] This could mean you sent one ident, and indicated ready on another.

3
Casey13:02:12

I'm fairly sure the case warned about in the error message doesn't apply because I'm using comp/get-ident in the call to post-mutation-params

(defsc QuizIndexPage [this {:keys [all-user-forms] :as props}]
  {:query         [{[:all-user-forms '_] (comp/get-query QuizListItem)}]
   :ident         (fn [] [:component/id :quiz-index])
   :route-segment ["quiz-index"]
   :initial-state {:all-user-forms []}
   :will-enter  (fn will-enter [app _]
                  (dr/route-deferred (comp/get-ident QuizIndexPage nil)
                                     #(df/load! app :all-user-forms QuizListItem
                                                {:post-mutation        `dr/target-ready
                                                 :post-mutation-params {:target (comp/get-ident QuizIndexPage nil)}})))})

Casey13:02:54

Not sure if this is related, but I've gotten this warning out of the box with fulcro-template

#error {:message "", :data {}}
 Attempt to get an ASM path 
[:com.fulcrologic.fulcro.ui-state-machines/local-storage :path-segment]
 for a state machine that is not in Fulcro state. ASM ID:  
:app.ui.root/TopRouter
Just ignored it for now. But https://webcache.googleusercontent.com/search?q=cache:xdQSQwODXGsJ:https://clojurians-log.clojureverse.org/fulcro/2020-02-14+&amp;cd=5&amp;hl=en&amp;ct=clnk&amp;gl=us&amp;client=firefox-b-d seems to indicate it is harmless.

Casey13:02:55

Figured it out 🙈 the state machine provided in the template for loading the session changes the route to main. https://github.com/fulcrologic/fulcro-template/blob/master/src/main/app/model/session.cljs I noticed a State Machine (BEGIN)*:app.ui.root/TopRouter* transaction was happening twice in the Fulcro dev tools. Once for my route and one later for "main"

Casey12:02:12

Ah and I just got to part 15-17 of the Fulcro 3 playlist which explains this in detail. Should have watched these before getting ahead of myself.