Fork me on GitHub
#cljsrn
<
2017-01-30
>
ejelome07:01:18

I'm literally confused how to actually do the this.props.onForward (and .onBack)

ejelome07:01:43

I can display the text, e.g. [touchable-highlight {:on-press <no-idea-here>} [text "Tap me to load the next scene"]], but I have no idea how can I actually call that function via this.props.onForward or this.props.onBack

levitanong09:01:11

@ejelome the code in onForward is all about pushing a new route onto stack.

levitanong09:01:08

the navigation object should contain information on what current route you’re in, and that helps you decide what view to show, given the route index or key.

levitanong09:01:35

I would recommend you use navigationExperimental though, because that’s the future, and they’ve said this is what they’re going to support in the future.

levitanong09:01:50

it’s also highly compatible with om.next

ejelome09:01:25

hey, thanks @levitanong, will look on that navigationExperimental, although for the meantime, I would like to do a 1:1 version of the samples, this is the last one afaik, I've tried this: core.cljs:

[navigator {:initialRoute {:title "My Initial Scene"
                           :index 0}
            :renderScene (fn [route, navigator_]
                           [my-scene {:title (.-title route)
                                      :onForward (fn []
                                                   (.push navigator {:title "Scene" (.-index route)
                                                                     :index (inc (.-index route))}))
                                      :onBack (fn []
                                                (if (pos? (.-index route))
                                                  (.pop navigator_)))}])}]
my_scene.cljs:
(def my-scene [props]
  [view
   [text "Current Scene: " (.-title props)]
   [touchable-highlight {:onPress (.-onForward props)}
    [text "Tap me to load the next scene"]]
   [touchable-highlight {:onPress (.-onBack props)}
    [text "Tap me to go back"]]])

ejelome09:01:08

unfortunately, it doesn't work

pesterhazy09:01:03

you probably need to pass a js data structure to .push

pesterhazy09:01:13

not a cljs data strcuture

ejelome09:01:37

thanks for the hint, and can I also know what's the proper way of calling props?

ejelome09:01:58

I feel like the above code is wrong, not just the data structure

levitanong09:01:16

i don’t think there’s anything wrong with (.push navigator)

ejelome09:01:21

esp. the way I accessed onForward and onBack

pesterhazy09:01:47

yeah you're strangely passing onForward to your own component (?)

levitanong09:01:08

my scene receives a javascript prop object

pesterhazy09:01:38

ah that's a translation of the example in the fb docs

levitanong09:01:54

but he’s passing a cljs object to my-scene

levitanong09:01:01

and accessing it like js

levitanong09:01:06

inside my-scene

ejelome09:01:54

right, that's just a 1:1 conversion from the docs

ejelome09:01:10

an attempt if I may add

pesterhazy09:01:53

well the problem is just in calling a reagent component

pesterhazy09:01:10

have you looked into reagent's documentation yet?

ejelome09:01:41

tbh, I just scratched the surface of reagent, then dove straight to re-natal

ejelome09:01:06

I will look on these things once I'm in my machine 🙂

pesterhazy09:01:07

so you don't need to pass on-forward etc at all

pesterhazy09:01:23

you need to make the navigator available to the component

pesterhazy09:01:52

one more problem

pesterhazy09:01:24

you need (r/as-element [my-scene ...]) in the render-scene fn

pesterhazy09:01:56

RN doesn't know how to do anything with clojurescript PersistenVectors

ejelome09:01:05

oh, I have that on my machine, forgot to type it again here XD, yes, I did that, but my main confusion was accessing the props

ejelome09:01:15

I'll back read all of these once I get back to my machine

ejelome09:01:31

thanks @levitanong and @pesterhazy, very helpful, appreciate it 🙂

pesterhazy09:01:58

you're welcome

pesterhazy09:01:24

It'd be great if you could add some docs on how to use the navigator here: https://github.com/mjmeintjes/boot-react-native/wiki/Using-React-Components

pesterhazy09:01:54

maybe even add your 1-1 translation of the navigator example in the RN docs?

pesterhazy09:01:06

that'd be super helpful to newcomers

ejelome09:01:23

oh, sure, I'd be happy to add info there 🙂

puppybits16:01:37

I'm trying to compile to run a re-natal/om-net project on an iOS device and I'm getting:

om-1.0.0-alpha41.jar!/om/externs.js:4: WARNING - name React is not defined in the externs.
Does this need to be manually added to the ios prod target?

pesterhazy17:01:19

you may not need to care about externs

pesterhazy17:01:47

personally I'm not convinced adv compilation makes much sense with react native

pesterhazy18:01:44

How on earth anyone thought renaming a header file was ever a good idea, I don't know honestly