This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-03
Channels
- # announcements (4)
- # beginners (68)
- # boot (3)
- # business (20)
- # cider (39)
- # cljs-dev (7)
- # cljsjs (1)
- # cljsrn (12)
- # clojure (122)
- # clojure-brasil (2)
- # clojure-italy (7)
- # clojure-nl (5)
- # clojure-spec (60)
- # clojure-uk (41)
- # clojurescript (67)
- # cursive (7)
- # datomic (13)
- # emacs (6)
- # figwheel-main (18)
- # fulcro (40)
- # garden (3)
- # graphql (2)
- # hyperfiddle (4)
- # jobs-discuss (10)
- # lein-figwheel (5)
- # leiningen (12)
- # luminus (6)
- # mount (3)
- # off-topic (52)
- # portkey (2)
- # re-frame (1)
- # reagent (6)
- # reitit (24)
- # shadow-cljs (15)
- # sql (3)
- # tools-deps (12)
I have a question related to ReactNavigation. I want to be able to reference the root navigator globally. In a regular React I can obtain the reference while rendering a component. How to do the same in CLJS/Reagent?
These are some notes we made while working through how to bolt react navigation together. https://confluence.condense.com.au/display/IZ/Navigating+between+screens - the relevant bit is the RootStack :ref
but perhaps the context is interesting.
I do see value in https://github.com/seantempesta/cljs-react-navigation having tried without a wrapper.
Or did I read that right. The screen containers get the navigator as a prop. That might be what you are asking.
(defn app-root []
[:> appnav/central-app-switch {:ref (fn [this] (dispatch [:set-root-navigator this]))}])
this basically does it - root navigator becomes a part of app-db and then you can reference it in effectful handlers
(reg-fx
:navigate
(fn [[root-navigator route params]]
(.dispatch root-navigator (navactions/navigate-to route params))))
(reg-event-fx
:handle-login-success
validate-spec
(fn [{:keys [db]} [_ session-info]]
(println db)
{:db (-> db
(assoc-in [:dcn-session] (-> session-info
(update-in [:userInfo :gender] keyword)
(update-in [:userInfo :siteRoles] (fn [v] (map #(keyword %) v))))))
:navigate [(:root-navigator db) :Main]}
))