This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-14
Channels
- # admin-announcements (5)
- # aws (3)
- # beginners (35)
- # boot (96)
- # cider (1)
- # clara (6)
- # cljs-dev (12)
- # cljsrn (34)
- # clojure (151)
- # clojure-boston (3)
- # clojure-brasil (4)
- # clojure-canada (1)
- # clojure-czech (8)
- # clojure-dusseldorf (11)
- # clojure-japan (5)
- # clojure-russia (120)
- # clojure-taiwan (1)
- # clojure-uk (3)
- # clojurescript (7)
- # component (27)
- # cursive (13)
- # data-science (45)
- # datomic (1)
- # devcards (5)
- # emacs (3)
- # funcool (65)
- # hoplon (103)
- # instaparse (3)
- # jobs (14)
- # jobs-discuss (1)
- # juxt (2)
- # lein-figwheel (2)
- # off-topic (16)
- # om (20)
- # onyx (49)
- # parinfer (17)
- # perun (1)
- # planck (5)
- # proton (4)
- # re-frame (14)
- # ring-swagger (4)
- # spacemacs (4)
- # untangled (110)
- # yada (14)
@alwx: it seems to have something to do with https://github.com/alwx/luno-react-native/issues/12
@frank: cool, thanks! @alwx - I’m very confused about making custom components. Reagent says to do it a certain way, but that doesn’t seem to work. In Luno, you pass a “wrapper function” in from the top level down to your components. Why? Why doesn’t reagent’s recommended method work?
Hmm… and it looks like your scenes are the same as reagents recommendation: a function returning a vector, called as a vector.
@seanhess the standard reagent method works when using RN.
I see from your example that you are adding a [text] directly to [touchable-highlight]
I have found that the RN components are sometimes very specific about what you can add to the native components
I would try to add a [view] to [touchable-highlight] first, then add [text] to that
[touchable-highlight [view [text "bob"]]]
@andre.richards: I’ll try that. But I copied what I have from the template. It has a text right inside the touchable-highlight. The only thing I did was try to move that text into another function / component. But otherwise it’s the lein template unchanged. See https://github.com/drapanjanas/re-natal/blob/master/resources/cljs-reagent/core.cljs
Yeah, I just tried it out, and they I showed it above does indeed work....
But if returning it from function it doesn't...
Give me a few minutes to try something
It looks like it’s failing because it’s inside the touchable-highlight, like you suggested
Yeah, so I not exactly sure the reason for this, but you are correct - as per your example, this is the error that gets written to console: 2016-04-14 17:16:56.349 [warn][tid:com.facebook.React.JavaScript] { [Invariant Violation: Touchable child must either be native or forward setNativeProps to a native component] line: 2307, column: 16, sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true', name: 'Invariant Violation', framesToPop: 1 }
Basically, this is how I ended up doing it (looking at some code from a couple of weeks ago): (defn press-me-label [name] [ touchable-highlight [text {:style {:color "white" :text-align "center" :font-weight "bold"}} (str "press me: " name)]])
Then you can do: [press-me-label "bob"] wherever you need the label
So I guess the problem is that reagent components are not forwarding setNativeProps?
Sounds possible, yes. Presumably, [view] and [text] do not have NativeProps, so not an issue for them?
(I'm also still pretty new to this :)
Or maybe touchable-highlight forwards them automatically, since it’s a react class. But if you put a component between touchable-highlight and text...
It’s forwarding the function to your in between component, which isn’t forwarding it in turn
I think they would
Thank you so much for your help @andre.richards, it’s hard to identify a bug when I’m new to everything, and assume I’m just doing it wrong
No worries, thanks for bug report. Also still feeling my way around, so know how you feel 👍