This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-19
Channels
- # beginners (59)
- # calva (20)
- # cider (25)
- # clj-kondo (12)
- # cljdoc (3)
- # cljsrn (15)
- # clojure (104)
- # clojure-europe (4)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-spec (14)
- # clojure-uk (13)
- # clojurescript (33)
- # code-reviews (26)
- # core-async (1)
- # cursive (5)
- # data-science (3)
- # datomic (8)
- # emacs (3)
- # fulcro (5)
- # graphql (3)
- # hoplon (1)
- # jobs-discuss (4)
- # kaocha (14)
- # nyc (1)
- # off-topic (33)
- # pathom (4)
- # pedestal (2)
- # quil (1)
- # re-frame (5)
- # reagent (10)
- # reitit (6)
- # rewrite-clj (3)
- # shadow-cljs (173)
- # specter (7)
- # sql (4)
- # vim (58)
- # yada (3)
[:> RN/FlatList {:data [1 2 3]
:renderItem
(fn [item] (r/as-element [text item]))}]
in cljs does use flatlist like this?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.
you need to do (to-array [1 2 3])
or something like that
it won’t accept a clojurescript vector
https://github.com/drapanjanas/re-natal/wiki/FAQ i found this, but it doesn't work
Oh the problem is that item is an object
Your render item method needs to get the data out
@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]
)
[:> RN/FlatList {:data #js[1 2 3]
:renderItem
(fn [item] (r/as-element [:> RN/Text {} item]))}]
i rewrite like this, the same error@danieleneal thanks, i just remove item as a "test" string, then ok, maybe the problem
@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
you can store the cljs data in a vector in an atom, but need to do (into-array @atom)
before passing to flatlist
@danieleneal great that works thanks