Fork me on GitHub
#reagent
<
2019-05-29
>
Stefan11:05:30

Hi! I’m trying to use react-native-view-overflow but I’m not sure how to type the required code in ClojureScript. I have the following inside one of my view components:

[:> rn/FlatList
     {:data (clj->js (mapv (fn [n] {:key n}) (range 0 100)))
      :horizontal true
      ;; :Item-separator-component #(r/as-element [separator])
      :render-item (fn [details] (r/as-element [cell (js->clj details)]))}]
According to the docs (https://github.com/entria/react-native-view-overflow#usage-with-flatlist) I need to wrap whatever I put into render-item with ViewOverflow. Just making the first thing in cell a ViewOverflow doesn’t seem to do the job…

Stefan11:05:36

For completeness, this is cell:

(defn cell [details]
  (let [item (details "item")
        key (item "key")]
    [:> rn/View {:style {:width 80
                         :background-color (if (= 0 (mod key 2)) "#dd666611" "#ffffff33")}}
     [:> rn/Text {:style {:left -15 :width 30 :text-align "center"}} key]]))

pcj15:05:19

Is there an easy way to tell if something is a SyntheticEvent?

lilactown16:05:30

@pcj there doesn’t seem to be an official way to do this, but an easy heuristic might be to check for the nativeEvent property

👍 4
colinkahn18:05:41

is it possible to use r/with-let inside a macro? AFAICT when it expands finally cannot be resolved, giving me Use of undeclared Var my.namespace/finally