Fork me on GitHub
#cljsrn
<
2019-08-19
>
vinurs02:08:08

[:> RN/FlatList {:data [1 2 3]
                     :renderItem
                     (fn [item] (r/as-element [text item]))}]
in cljs does use flatlist like this?

vinurs02:08:50

it reports Invariant Violation: Objects are not valid as a React child (found: object with keys {item, index, separators}). If you meant to render a collection of children, use an array instead.

danielneal09:08:07

you need to do (to-array [1 2 3]) or something like that

danielneal09:08:26

it won’t accept a clojurescript vector

vinurs13:08:31

i use #js [1 2 3] but it reports the same error

vinurs13:08:11

does someone can give me a example for flatlist?

danielneal14:08:15

Oh the problem is that item is an object

danielneal14:08:31

Your render item method needs to get the data out

thheller15:08:15

@haiyuan.vinurs what is [text item]? seems like you probably want (r/as-element [:> RN/Text {} item]) (and passing an array to react via :data (into-array [1 2 3]) or :data #js [1 2 3])

vinurs21:08:33

@thheller

[:> RN/FlatList {:data #js[1 2 3]
                     :renderItem
                     (fn [item] (r/as-element [:> RN/Text {} item]))}]
i rewrite like this, the same error

vinurs21:08:41

@danieleneal thanks, i just remove item as a "test" string, then ok, maybe the problem

Mark W21:08:26

@danieleneal thanks for the suggestion....how do you reset the cljs vector before calling into-array based upon user input then? what i'm trying to do is have a text-input whose value filters the flat-list but i'm at a loss as to how to capture this change and re-render the flat-list if not using an atom

danielneal08:08:20

you can store the cljs data in a vector in an atom, but need to do (into-array @atom) before passing to flatlist

Mark W20:08:55

@danieleneal great that works thanks