This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-18
Channels
- # announcements (6)
- # babashka (16)
- # beginners (194)
- # calva (20)
- # cider (34)
- # clj-kondo (38)
- # clojure (89)
- # clojure-europe (10)
- # clojure-finland (15)
- # clojure-italy (2)
- # clojure-nl (15)
- # clojure-sg (7)
- # clojure-spec (15)
- # clojure-uk (86)
- # clojurebridge (1)
- # clojurescript (60)
- # community-development (11)
- # conjure (13)
- # core-async (48)
- # core-typed (3)
- # cursive (22)
- # datascript (8)
- # datomic (40)
- # duct (11)
- # emacs (3)
- # figwheel-main (22)
- # fulcro (45)
- # graphql (1)
- # helix (9)
- # hoplon (15)
- # hugsql (7)
- # jobs-discuss (47)
- # juxt (7)
- # kaocha (21)
- # luminus (1)
- # malli (13)
- # meander (2)
- # off-topic (52)
- # parinfer (19)
- # re-frame (66)
- # reagent (1)
- # reitit (3)
- # ring-swagger (1)
- # rum (2)
- # shadow-cljs (72)
- # spacemacs (5)
- # sql (4)
- # timbre (5)
- # tools-deps (15)
- # vim (5)
- # vrac (7)
hello i need little bit clarification if someone could shed some light
so i created an app (react native) and i wanted to create view
that is aware of it's orientation. so i made
(defn view [& [props & children]]
(let [config (rf/subscribe [:app-config/all])]
(fn []
(let [{:keys [orientation]} @config]
(reduce (fn [base child]
(conj base child))
[:> rn/View (merge {:style {:flex 1
:flex-direction orientation}}
props)]
children)))))
and it worked ok until i used it in this way
[comps/view
{}
[:> rn/View {:style {:flex 1
:padding 10
:justify-content :space-around
:align-items :center
:background-color :red
}}
[:> rn-elem/CheckBox {:center true
:title "BUY"
:checked-icon :dot-circle-o
:unchecked-icon :circle-o
:checked (= @action :buy)
:on-press #(reset! action :buy)
:checked-color :black}]
[:> rn/Text {:style {:font-weight :bold
:font-size 24
:color :black}} "OR"]
[:> rn-elem/CheckBox {:center true
:title "SELL"
:checked-icon :dot-circle-o
:unchecked-icon :circle-o
:checked (= @action :sell)
:on-press #(reset! action :sell)
:checked-color :black}]]]
action
is ratom defined in let fn before this
and the thing is that checkboxes didn't work
but when i used
(defn view [& [props & children]]
(let [config (rf/subscribe [:app-config/all])]
(reduce conj [:> rn/View (merge {:style {:flex 1
:flex-direction (:orientation @config)}}
props)]
children)))
everything works
Does anyone know why?
As soon as i return fn
in the view things start to break and i don't understand why