This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-17
Channels
- # announcements (4)
- # beginners (82)
- # boot (1)
- # calva (26)
- # cider (13)
- # clj-kondo (41)
- # cljs-dev (25)
- # cljsrn (7)
- # clojure (82)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dev (13)
- # clojure-europe (11)
- # clojure-italy (27)
- # clojure-nl (8)
- # clojure-russia (6)
- # clojure-spec (32)
- # clojure-uk (15)
- # clojurescript (61)
- # core-async (1)
- # cursive (9)
- # data-science (1)
- # datomic (18)
- # duct (1)
- # emacs (2)
- # events (7)
- # fulcro (13)
- # graalvm (5)
- # immutant (1)
- # jobs-discuss (63)
- # leiningen (3)
- # off-topic (48)
- # om (3)
- # pathom (13)
- # planck (20)
- # prelude (3)
- # re-frame (55)
- # reagent (13)
- # reitit (5)
- # rewrite-clj (12)
- # shadow-cljs (67)
- # spacemacs (14)
- # sql (5)
- # tools-deps (4)
- # vim (23)
- # yada (2)
Hi, a question about routers nested somewhere in the component tree: I had an issue with the router's props disappearing after performing a load with the component that hosts the router. My current solution is to modify the load like this:
(df/load-action env [:mx.study/by-id study-id] Study {
:marker :ui/loading-study
:initialize {:report-router [:fulcro.client.routing.routers/by-id :report-router]}
:without #{:report-router}})
using :inititalize
and :without
in the load-action, is this the correct way to do it or is there a more idiomatic way to avoid/solve this issue?
So what this achieves, is that merging the result of the load-action doesn't mess up the router-instruction that sets the report id in the report-router that is nested a few levels under the Study component
Worked fine with leiningen setup. With shadow-cljs and deps.edn for the server it tries to connect cljs to the running shadow-cljs clj repl from the file .nrepl.port. This does not work, but manually entering the same port number as the clj repl works here.
Thanks @U0P1MGUSX and @U15BH4U4V !
or slightly better than the above: use a :pre-merge
on the component that hosts the router instead of the :initialize
at load time
Right, pre-merge is the more recent addn to the system that is meant to address these kinds of issues since it localizes the concern to the UI components and not the load.
Another approach is to use a ui
prefix on the router, or add a global query transform to the data fetch system that elides other keyword prefixes (e.g. :router/*
) so that you can adopt a naming convention that will avoid having the thing be part of the graph query.
depends on if you need occasional initialization or not…pre-merge allows you to do work (for example if the router itself wasn’t part of the tree yet), and the other approach avoids making the load accidentally include the router.
I personally prefer making sure (via the :ui/
prefix) that the routers and such never end up in a load accidentally.
👍 I'll give the prefix :ui/
a try, that's the cleanest approach for sure.