reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
lepistane 2020-06-18T10:51:56.170Z

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