Clojurians
#cljsrn
<
2015-12-01
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

gphilipp08:12:36

Now, I’m using https://github.com/brentvatne/react-native-linear-gradient, and almost got it to work following exactly the same steps as we did above for the TableView. I have an issue with translating the colors from cljs to js :

(lineargradient {:colors ["#4C669F" "#3B5998" "#192F6A"]}
                                      (text nil "Login" ))
will fail with JSON value ‘#4C669F’ of type NSString cannot be converted to NSNumber. Here what I see in the repl when trying to convert the data structure :
(clj->js ["#4C669F" "#3B5998" "#192F6A"])
=> #js ["#4C669F" "#3B5998" "#192F6A »]

. What am I doing wrong ?

gphilipp08:12:38

Note that

(lineargradient {:colors [0x4C669F 0x3B5998 0x192F6A]}
                                      (text nil "Login"))
doesn’t show up the colors but at least doens’t throw exceptions...

artemyarulin08:12:49

(clj->js should it be before colors?

artemyarulin08:12:13

I mean probably you should convert the whole style

artemyarulin08:12:45

(lineargradient (clj->js {:colors ["#4C669F" "#3B5998" "#192F6A”]}) (text nil "Login" ))

gphilipp09:12:43

I forgot to say I declared the following earlier in the namespace:

(def LinearGradient (js/require "LinearGradient"))
(defn lineargradient [opts & children]
    (apply js/React.createElement
           LinearGradient (clj->js opts) children))

gphilipp09:12:13

So in theory

(lineargradient {:colors ["#4C669F" "#3B5998" "#192F6A"]}
                                      (text nil "Login" ))
is supposed to work as is.

artemyarulin09:12:30

well, then the only way is to check the compiled code, set a break on createElement and see what is inside. Components expect just a string, so CLJS shouldn’t break it

gphilipp15:12:19

Well, I’m investigating how to do that. I’ve stepped into the Chrome debugger, but where is the generated code (something like main.js when doing regular Om) ? I see index.ios.js and the content of index.ios.bundle?platform=ios&dev=true but neither contains my core namespace code (generated to js).

artemyarulin17:12:35

sry, I’m not using natal or ambly, cannot tell

artemyarulin22:12:48

good to know. One thing that I learned with RN - always be on a edge, 0.12 is quite old