Fork me on GitHub
#reagent
<
2015-12-09
>
gabe15:12:26

Trying to use a reagent component inside the props of a react component:

gabe15:12:16

[ui/app-bar {:icon-element-right [my-component]}]

gabe15:12:28

i know this isn’t the right way, but what is?

eyelidlessness16:12:22

if you want to reference the component directly, my instinct is to reference it without the vector, and put it into a vector in app-bar. but i'd consider abstracting that a bit, using a keyword value for :icon-element-right and letting app-bar decide how to use that param

gabe16:12:02

i should have mentioned that ui/app-bar is a proxy for MaterialUI.AppBar

gabe16:12:19

from the MaterialUI React component library

gabe16:12:27

I don’t have control over what it does

eyelidlessness16:12:16

you may want something like [ui/app-bar {:icon-element-right (my-component)}] but that feels gross

eyelidlessness16:12:06

does it really expect components as params, rather than as children?

gabe16:12:34

i’ll see if there’s another method, but yes

eyelidlessness16:12:10

i've never really used react outside of cljs, but that SEEMS unidiomatic to me

eyelidlessness16:12:16

no that that helps you here

eyelidlessness16:12:18

digging through reagent rendering flow, it appears that they use reagent.impl.template/as-element to convert the vector into react dom

gabe16:12:46

so maybe reagent/create-element?

jaen16:12:54

Yeah, as-element should help.

gabe16:12:18

as-element FTW

jaen16:12:46

Also material-ui, heh. How do you pack it up out of curiosity?

eyelidlessness16:12:58

granted going into impl is not necessarily advised

gabe16:12:12

@eyelidlessness: it’s publicly exposed

gabe16:12:43

@jaen: made a macro that calls reagent.core/adapt-react-class on a list of MaterialUI components i want

gabe16:12:42

I’d like to not have to list them explicitly, but it works for now

gabe16:12:29

had to do a bit of fiddling to get it working w/ latest MaterialUI and React

gabe16:12:41

And added camel->snake case

jaen16:12:01

I mean, what do you use to compile the modules out. Webpack? Browserify?

gabe16:12:08

Browserify

gabe16:12:29

if i get it packaged up cleanly i’ll put it up on Github

gabe16:12:28

Also not sure how it’ll work w/ advanced compilation

jaen16:12:45

Well, if you compile the modules away

jaen16:12:49

You only need externs

gabe16:12:12

right. but then features...

gabe16:12:43

i’ll shout out if i release it

jaen16:12:47

I was so crazy that once time I actually started hacking on Clojurescript compiler so it accepted Common JS libraries as-is.

jaen16:12:51

It kinda worked

gabe16:12:03

there’s a project to do that

jaen16:12:35

But didn't mesh with advanced compilation unfortunately.

jaen16:12:40

Oh, is there?

jaen16:12:06

Maybe there's something I wasn't aware of, but I'm no so sure.

gabe16:12:14

Maria Geller was doing a Google SOC project

gabe16:12:54

she gave a talk at the Conj

jaen16:12:16

But that's not enough

jaen16:12:21

I was building up on what she's done

jaen16:12:32

Which is awesome she started on that

jaen16:12:40

But it was not enough to work with whole libraries

jaen16:12:43

Just single files

jaen16:12:53

And you had to specify all files by hand and so on.

gabe16:12:32

is your fork public?

gabe16:12:24

nm…i see it

jaen16:12:07

This one is slightly better IIRC

jaen16:12:00

Though the older one can deal with material-ui, the newer didn't yet I think.

jaen16:12:13

But in the end there wasn't that much interest in it I think

gabe18:12:09

@jaen: cool. i’ll check it out!

eggsyntax19:12:16

It would be excellent, if we ultimately moved past having to specify externs -- I just went through it for the first time, with a fairly complex JS library, and while it's fairly easy once you understand it, it definitely requires some time to understand in the first place.

eggsyntax19:12:50

LOL, I should set up a consultancy to write people's externs files for them, save other people the hassle 😉

gadfly36119:12:33

Ha, i'd use your extern sercives lol

eggsyntax19:12:17

@gabe: I didn't catch Maria's talk at the conj -- how far did she get?

gadfly36119:12:35

I dont like externs, and i am weary of cljsjs

eggsyntax19:12:45

...on the externs part, that is.

eggsyntax19:12:36

I like cljsjs fine, but there are so many libs that aren't in it yet...although it was gratifying to add on and chip away slightly at that list 😉

jaen19:12:06

I'm not sure if there's anything on the externs generation front in the Clojurescript compiler right now.

gabe19:12:29

@eggsyntax: she didn’t really talk about it at the Conj. i just recall seeing some of the work a couple of months ago

jaen19:12:37

:module-option option as described here - https://github.com/clojure/clojurescript/wiki/Compiler-Options#foreign-libs - is about the only 100% finished part.

jaen19:12:13

I'm a bit disappointed it stopped at this point - hence why I started hacking on it - but it feels as if upstream isn't really all that interested in it : V

eggsyntax19:12:47

@jaen Interested in the externs part, you mean?

jaen19:12:26

Well, there's probably more interest in that, I was talking about incorporating module conversion into the compiler. But I don't think there was any work done on that since either.

gabe19:12:34

i didn’t know about the entry point flags

gabe19:12:01

but we are pretty off-topic

jaen20:12:02

Heh, it's all a bit tricky in practice - for example you can't really translate module names to usual.clojure.module.namespaces because due to how GClosure modules work it will overwrite Javascript module structures and such.

jaen20:12:09

But yeah, I guess that's somewhat off-topic.

eggsyntax20:12:07

I gave that a shot at one point, but couldn't get it to work for me. Note the 2009 date. I didn't try that hard, though. Looking at the last link @jaen posted, though,, I saw it mentioned this lein plugin, which I hadn't run across before: https://github.com/ejlo/lein-externs

gabe20:12:27

now THAT looks interesting