Fork me on GitHub
#clojure
<
2017-10-12
>
dpsutton00:10:28

@qqq there's cider-eval-print-last-sexp which should do what you were asking

qqq00:10:22

@dpsutton: precisely what I wanted; thanks!

sachinharpalani05:10:47

Hi, im currently using cljs for react-native app and having some issue in the interop of HighOrderComponent. The library i want to use is : https://github.com/okgrow/react-native-joyride This the the js code i wanna interop:

import { joyride } from 'react-native-joyride';

class HomeScreen extends Component { /* ... */ }

export default joyride()(HomeScreen);
I have a function that has the homescreen page component,im facing difficulty in export statement. Any help would be appreciated 😃

sundarj08:10:08

there's no equivalent to export default in cljs

sundarj08:10:19

i suppose you could do (def default ...)

sachinharpalani09:10:59

@U61HA86AG i have used (def ^:export filename) but yes i cannot find a way to export it as default

sundarj09:10:03

^:export just means it will retain its full path in the final js (e.g some.namespace.foo())

sundarj09:10:19

it is not possible to export something as default in cljs

sachinharpalani09:10:28

@U61HA86AG okay cause i seem to be getting the following issue:

[Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.]
I googled this and it normally happens with incorrect import/export. Dont know what to do 😞

sachinharpalani09:10:37

@U61HA86AG This is the only library i found that gives me a tourguide/ walkthough for new users, do you know any similar library that does that?

sundarj09:10:04

looking at that readme, there's nothing that says you must export as default

sundarj09:10:28

so the error is in the code that's importing your component namespace

sachinharpalani09:10:11

@U61HA86AG this is my updated code for which i am getting the above error:

(def joy (.joyride JoyRide))
(def JoyrideStep  (r/adapt-react-class (.-JoyrideStep JoyRide)))
(def JoyrideText (r/adapt-react-class (.joyridable JoyRide (r/reactify-component (.-Text ReactNative)))) )

(defn ^:export joyride-page []
  [view
   [JoyrideStep (clj->js {:text  "Hey! This is the first step of the tour!"
                          :order 1
                          :name "openApp"})
    [JoyrideText "Welcome to the demo of joyride library"]])

(defn m-joyride-page []
  (let [m (-> joyride-page
              r/reactify-component
              joy
              r/adapt-react-class)]
    [m]))
The flow is going till joyride-page but it seems JoyRideStep is causing the error.

sundarj10:10:13

if view is defined, and JoyRideStep is undefined, then that means that (def JoyrideStep (r/adapt-react-class (.-JoyrideStep JoyRide))) is not doing what you expect

sundarj10:10:13

(i am not familiar with whatever that cljs React wrapper is)

sachinharpalani10:10:30

@U61HA86AG (def JoyrideStep (r/adapt-react-class (.-JoyrideStep JoyRide)) is taking joyride step and converting into react component wrapper

sachinharpalani10:10:07

@U61HA86AG i have defined view in similar way (def view (r/adapt-react-class (.-View ReactNative))) and it seems to be working

sundarj10:10:09

i figured, but if it's undefined (as per the error you got), then there must be something wrong with it, right?

sachinharpalani10:10:51

@U61HA86AG I agree, im stuck on that because it should work as it is supposed to but it isnt, i thought it a js<->clj interop issue but i doubt that too

sundarj10:10:30

how are you requiring JoyRide? it might be (.-JoyrideStep js/JoyRide) or JoyRide/JoyrideStep instead

sachinharpalani10:10:44

This is how im requiring JoyRide (def JoyRide (js/require "react-native-joyride"))

sachinharpalani10:10:04

JoyRide/JoyrideStep I dont think so this works in cljs

sundarj10:10:37

hmm, in that case i think it should work, perhaps you need to (.log js/console JoyRide) and validate your assumptions

sachinharpalani10:10:01

@U61HA86AG i tried replacing it to (def JoyrideStep (r/adapt-react-class JoyRide/JoyrideStep)) but i get this issue

[TypeError: undefined is not an object (evaluating 'expo_demo.core.JoyRide.joyride')]

sundarj10:10:41

that must mean JoyRide is undefined?

sachinharpalani10:10:06

I guess joyride is undefined

sundarj10:10:47

so the js/require is not working i guess

sachinharpalani10:10:54

@U61HA86AG sorry you were right it was a js/require silly issue i made . This is the error i get [ReferenceError: Can't find variable: JoyRide]

sachinharpalani10:10:02

using log on joyride gives me this

Object {
  "JoyrideStep": [Function JoyrideStep],
  "joyridable": [Function joyridable],
  "joyride": [Function joyride],
}

sundarj10:10:44

then .-JoyrideStep on that should work, right?

sachinharpalani10:10:28

@U61HA86AG im getting the following Object only after changing it to .-JoyrideStep

sachinharpalani10:10:23

log on JoyrideStep gives me

{
  "class": null,
  "id": null,
  "name": [Function JoyrideStep],
}

sachinharpalani10:10:55

It seems im getting null on JoyrideStep

sachinharpalani10:10:15

and log on JoyrideText gives

{
  "class": null,
  "id": null,
  "name": [Function anonymous],
}

sundarj10:10:50

then i suppose you might need to do (def JoyrideStep (.-name (.-JoyrideStep Joyride))

sundarj10:10:03

and the same for JoyrideText

sachinharpalani10:10:37

i dont have to convert it by (r/adapt-react-class)?

sundarj10:10:57

i don't know about that, sorry

sundarj10:10:34

looks like a Reagent thing - you might try #reagent

sachinharpalani10:10:02

@U61HA86AG using

(def JoyrideStep  (.-name (.-JoyrideStep JoyRide)))
(def JoyrideText (.-name (.joyridable JoyRide (r/reactify-component (.-Text ReactNative)))))
gives the following issue :
Error rendering component (in env.main.reloader > expo_demo.core.app_root > m-joyride-page >  > expo_demo.core.joyride_page)
15:58:40
[Error: Assert failed: Invalid tag: '' (in env.main.reloader > expo_demo.core.app_root > m-joyride-page >  > expo_demo.core.joyride_page)
tag]

sachinharpalani10:10:17

So i need to use (r/adapt-react-class)

sachinharpalani10:10:49

using

(def JoyrideStep  (r/adapt-react-class (.-name (.-JoyrideStep JoyRide))))
(def JoyrideText  (r/adapt-react-class (.-name (.joyridable JoyRide (r/reactify-component (.-Text ReactNative))))))
gives me the following error :
[Invariant Violation: Expected a component class, got [object Object].]
and log of JoyrideStep and JoyrideText of the same is
{
  "class": null,
  "id": null,
  "name": "JoyrideStep",
}  {
  "class": null,
  "id": null,
  "name": "",
}

sundarj10:10:29

guess that's wrong too then, sorry 😞

sachinharpalani10:10:00

@U61HA86AG np btw could you explain me why (.-name) had to be used? i dont know js actually

sundarj10:10:47

i just figured that you needed the component function, which seemed to be under the name property of that object. was a complete guess 😛

sachinharpalani10:10:50

@U61HA86AG oh so when are the cases in which we need to use (.-name). I have used many libraries but never need to use this

sundarj10:10:57

that object you posted had the property name, which had a function value. the others were both null, so i guessed that you needed the function. to get the name property of a js object you use the .-name interop syntax

sachinharpalani10:10:20

@U61HA86AG i understood for JoyrideStep but for JoyrideText has name earlier as [anonymous function] so how to access this?

sachinharpalani10:10:47

and after using (.-name) on JoyrideText the name is ""

sundarj10:10:24

the name property of an anonymous function is ""

sundarj10:10:29

so that's what's happening there

sundarj10:10:41

JoyrideText must already be a function

sachinharpalani10:10:24

@U61HA86AG JoyrideText must already be a function means?

sundarj10:10:18

if it was the object it would .-name would return a function, not a string

sundarj10:10:37

(.-name some-anonymous-fn) returns ""

sachinharpalani10:10:10

so you mean to say JoyrideText is a function and not object?

sachinharpalani10:10:36

@U61HA86AG so i cannot use (.-name) in JoyrideText

sundarj10:10:15

.-name didn't work anyway right

sachinharpalani10:10:27

true but it did change my error from

[Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.]
to
[Invariant Violation: Expected a component class, got [object Object].]

sachinharpalani10:10:39

so i think that was the correct direction

sachinharpalani11:10:39

@U61HA86AG thanks alot for your help

sundarj11:10:19

no worries! pity we couldn't figure it out 🙂

sachinharpalani11:10:59

@U61HA86AG i just found out there is a dedicated channel #cljsrn for react native using cljs ill try posting it there

sundarj11:10:11

good luck!

qqq08:10:53

are there any benchmarks of mow much more expensive exceptions are than returning nil ?

wilcov10:10:54

Is it possible to mark messages as spam in slack? can't seem to find it

danm10:10:25

I do not believe so. I mean, Slack is designed as an invite-only system isn't it, although there are some automated tools people have written around that to allow anyone to sign up

danm10:10:57

But I suspect the expectation is if you get spammed you just uninvite/ban the user from your Slack workspace

wilcov11:10:50

that makes sense

dominicm13:10:08

@wilcov the recent slack @everyone disabling was evidence of how slack views "open" systems

cddr13:10:29

Never seen it so quiet in here. I guess everyone is having their minds 💥 at the conj.

bja14:10:57

is this conj this week? I thought it's normally in november. edit: yes it is this week.

lovuikeng16:10:36

thank you! @mpenet I really missed his talks 🙂

lvh18:10:43

Is there a trick for (in constant time) turning a LazySeq that’s already fully realized into an IPersistentList? I’m assuming there’s nothing smarter than reify.

noisesmith18:10:51

why are you targeting that specific interface?

bja20:10:44

unsure who runs ClojureTV on Youtube, but this talk is mislabled: https://www.youtube.com/watch?v=B_ubbbm9cRg. The title claims it is "Homoiconicity : It Is What It Is" by Stuart Sierra but the video is "Learning Clojure and Clojurescript by playing a card game" by Gijs Stuurman

seancorfield21:10:12

That’s been fixed. BTW, Stuart’s talk had a technical issue with audio, so he will re-do the audio and it’ll get posted in a day or so.

grav20:10:49

“It’s hard enough to drive a car. If you’ve got to understand monads too …“ 😄