Fork me on GitHub
#reagent
<
2017-05-14
>
kurt-o-sys20:05:04

Hey all, I'm trying to get the scrollTo...-methods of RN's https://facebook.github.io/react-native/docs/virtualizedlist.html (or flatlist) to work. I tried with rum, without success, so I switched to reagent, without any luck so far. There are no errors, but the scrolling just doesn't happen. Here's some code:

;; component to render each item
(defn list-item
  [item]
...)

;; just using a new project
(defn app-root []
  (r/create-class  ;; trying to 'translate' javascript to reagent ()
   {:component-did-mount
    (fn[this]
      (let [flatlist (-> (.. this -refs)
                         js->clj
                         (get "qa-list"))]
        (println  flatlist)  ;; this gives '#object[FlatList [object Object]]'
        (.scrollToEnd flatlist) ;; doesn't work, as any other .scrollTo-method (no error, but no scrolling either)
        ))
    :reagent-render
    (let [greeting (subscribe [:get-greeting])]
      (fn []
        [view {:style {:flex-direction "column" :margin 40 :align-items "center"}}
         [text {:style {:font-size 30 :font-weight "100" :margin-bottom 20 :text-align "center"}} @greeting]
         [virt-list {:data all
                     :keyExtractor (fn [item idx] (str "list-item::" idx))
                     :ref          "list-list"
                     :renderItem   (fn [item] (r/as-element (list-item item)))}]]))}))
Anyone got the scrollTo-methods of running yet in reagent/cljsrn?

kurt-o-sys20:05:54

Oh yeah: (def virt-list (r/adapt-react-class (.-FlatList ReactNative))) and (def all [...])

kurt-o-sys20:05:40

(I tried both VirtualizedList and FlatList)