Fork me on GitHub
#cljsrn
<
2016-10-11
>
nikki04:10:28

if you get an error compiling a module like

nikki04:10:30

notifying browser that file changed:  out/cljstest/core.js
Compiling "target/not-used.js" from ["src" "env/dev"]...
Successfully compiled "target/not-used.js" in 0.306 seconds.
notifying browser that file changed:  out/cljstest/core.js

nikki04:10:36

how do you track down the actual underlying error?

misha07:10:44

@nikki lein cljsbuild once

knotschi08:10:42

@pesterhazy yes a blog posts about TextInputs would be nice 😄

knotschi09:10:19

I had an other problem, because I wanted to have a property to focus a field. It is pretty ugly with reagent to get access to the javascript object of the input element to call focus on it. I ended up with an ugly solution. but maybe with a similar way you could create your own property that you can use to clear the input field: https://gist.github.com/Knotschi/6f97efe89681ac149113ddec4c396cc5

knotschi12:10:46

oh, nice, thanks. I totally missed that you can use ref as a callback function instead of a string property. thats indeed much more elegant.

knotschi12:10:55

even though the whole thing still feels a bit hacky 😄 unfortunately the react native guys are not willing to add a "focus" attribute to TextInput fields

pvinis16:10:11

[touchable-highlight {:style (styles :wrapper)
                          :on-press #(.alert (.-Alert ReactNative) "Alert Title" "alert-message” (clj->js[{:text "OKd"   
                                                                                                                                                     :onPress (fn [] (.log console 3))}])}

pvinis16:10:55

in this case, how can i write the inside :onPress?

pvinis16:10:26

the alert gets an array of objects, that have text and onPress. the second being a function

pvinis16:10:04

how can i do that in cljs? can i somehow have a function inside a clj->js ?

misha20:10:11

@pvinis the way you wrote it should work. except maybe not console, but js/console. here's what I have (for rum though):

(defn alert
  ([title]
   (.alert (.-Alert ReactNative) title))
  ([title msg]
   (.alert (.-Alert ReactNative) title msg))
  ([title msg buttons]
   (.alert (.-Alert ReactNative) title msg (clj->js buttons))))

(defn alert-button
  ([txt]
   #js {:text txt})
  ([txt on-click]
   #js {:text txt :onPress on-click}))

misha20:10:31

actually, try replacing (clj->js [{...}]) with [#js {..}], because:

cljs.user=> (clj->js [{:text "OKd" :onPress (fn [] 3)}])
#js [#js {:text "OKd", :onPress #object[Function "function (){return (3);}"]}]

cljs.user=> [#js {:text "OKd" :onPress (fn [] 3)}]
    [#js {:text "OKd", :onPress #object[onPress "function (){return (3);}"]}]