Fork me on GitHub
#cljsrn
<
2017-08-24
>
tiensonqin01:08:30

Hi, I’m looking for a remote (GMT+8) Clojure(script) position (full-time or contract), I’m the original author of https://github.com/seantempesta/expo-cljs-template and https://github.com/tiensonqin/lymchat. Looking forward to talk with you!

zlrth01:08:57

i learned a bunch about cljs + rn by reading lymchat’s source!

tiensonqin02:08:33

@mfm Thank you very much.

manu09:08:06

Do you know how to write the tabBarIcon here

class MyHomeScreen extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Home',
    // Note: By default the icon is only shown on iOS. Search the showIcon option below.
    tabBarIcon: ({ tintColor }) => (
      <Image
        source={require('./chats-icon.png')}
        style={[styles.icon, {tintColor: tintColor}]}
      />
    ),
  };

  render() { 
with clojurescript? I'd like to add and icon to my tabnavigator but I have aridity error :thinking_face:

manu09:08:49

Here is how I've written

(TabNavigator
    (clj->js {:swipeEnabled true
              :initialRouteName "boxes-view"
              :tabBarPosition "bottom"
              :navigationOptions {:tabBarVisible true

                                  :tabBarIcon (fn [{:keys [tintColor]}][Image {:source (js/require "./images/linfa_logo.png") :style {:tintColor tintColor} }])
                                  }})) 

manu13:08:48

Hi! what this symbol :> means?

seantempesta13:08:15

@manu: That tells Reagent to expect a React component, rather than a Reagent component.

manu13:08:54

@seantempesta thanks! I saw it on your repository cljs-react-navigation!

seantempesta13:08:09

Yeah…I need to remove those. It just confuses people.

manu13:08:19

but I cannot undestand how do you import it

seantempesta13:08:40

How you import my library?

manu13:08:37

I mean, I don't undestand how do you import that symbol

manu13:08:33

what can I use instead of :>?

manu13:08:50

adapt-react-class?

seantempesta13:08:18

(def image (r/adapt-react-class Image))

seantempesta13:08:07

You don’t have to import any symbol to use :>. When Reagent is reading the vector it checks to see if the first element is that symbol. Then it assumes the rest of the vector is a react component.

seantempesta13:08:10

[:> Image {:source "asdf.jpg"}] Will automatically adapt the Image class and convert the props to js using clj->js

manu13:08:32

I'm trying to put an icon to the tab of the tabnavigator

manu13:08:09

I saw you did it by useng Ionicons

danielneal13:08:02

hahah yeah that symbol is so confusing because you can't google it!

danielneal13:08:16

or even search the source for it

danielneal13:08:27

when I first saw it I was like wat 🙃

manu13:08:03

I'm trying with Image but I have an error

manu13:08:56

@seantempesta this is my code

(def Boxes-View (r/reactify-component boxes-view))
(def img* (adapt-react-class (.-Image react)))
(aset Boxes-View "navigationOptions" (clj->js {:tabBarLabel "Home"
                                               :tabBarIcon (fn [{:keys [tintColor focused ]}]
                                                            [img* {:source (js/require "./images/linfa_logo.png") :style {:tintColor tintColor} }])})) 

manu13:08:53

I've this error

Objects are not valid as a React child (found: object with keys {name, id, class}). If you meant to render a collection of children, use an array instead 

seantempesta14:08:28

@manu: You might have to render an element as the return value for the tabBarIcon fn.

seantempesta14:08:06

I found it incredibly confusing to remember when to convert the props or when to return a component vs an element, so I created the cljs-react-navigation library to take care of those details.

manu14:08:56

what is the difference between element and component? :thinking_face:

seantempesta14:08:56

I think you can do that via (r/as-element [img* {:source (js/require "./images/linfa_logo.png")...])

seantempesta14:08:17

I believe an element is an instance of a component.

manu14:08:08

great! now it is working!!

seantempesta14:08:13

But if you use my library it’ll take care of all the converting for you.

manu14:08:20

thanks a lot!! ❤️

manu14:08:57

unfortunately I've just discovered your library

manu14:08:51

and i spent a lot of time in updating from react-navigator to react-navigation

manu14:08:20

and now I'm almost at the end of the project

seantempesta14:08:22

Yeah. I banged my head against several walls until I finally gave up and just decided to spec the entire API. They don’t make it easy either! Most of it isn’t documented so you have to dig around in the source code to figure out what the attributes are and what the expected return values need to be.

manu14:08:07

your repository is a good example of how to use them! 😄

manu14:08:49

I'll use your project next project! for now thanks for made it 😄

seantempesta14:08:59

Thanks! Github stars are appreciated. I’m looking for some contracting work at the moment, and I think those stars help. 🙂