Fork me on GitHub
#reagent
<
2018-02-12
>
beetleman08:02:55

and this is way to block propagation on some event:

beetleman08:02:59

(defn stop-propagation [e]
  (.stopPropagation e))

(defn component []
  [:> Foo {:on-drag stop-propagation}])

eveko11:02:16

Hello, how would one use js interop to change inner html of a reagent div?

eveko11:02:42

[:div {:id "elId"}] (set! (. (. js/document getElementById "elId") -innerHTML) "<b>Bold!</b>")

eveko11:02:45

this does not seem to work

eveko11:02:30

cheers thanks allot

sggdfgf12:02:25

how can I understand what [:> exactly expands into. is it same as (reagent/create-class { so I can write [:> :reagent-render [:hiccup]... and so on?

gadfly36112:02:49

Section on better interop with native react

sggdfgf12:02:02

@gadfly361 hanks I can see now! so I can override any lifecycle method on adapted class like [:> :component-did-mount or I do have to wrap it into my own class.

gadfly36112:02:36

I don't think you can do that unfortunately

sggdfgf12:02:22

Only just construction props into here [:> I guess then? :thinking_face:

sggdfgf12:02:57

@gadfly361 an other user @mateusz.probachta advised that `(defn component [] [:> Foo {:on-drag stop-propagation}])` would work and it does on some cases. Right now I am very puzzled. :face_with_monocle:

gadfly36112:02:04

@faxa i think you are confused because :> is syntactic sugar for adapt-react-class .. not create-class

justinlee17:02:59

@faxa according to the link above it is sugar for [(adapt-react-class ReactComponent) props]. it has no documentation other than that single paragraph and it is basically impossible to search for, so i’d stick with adapt-react-class if i were you 🙂

justinlee17:02:15

i can’t even find its definition in the code

mikerod17:02:33

The case where pos = 0

justinlee17:02:49

@mikerod ahh! that’s why i couldn’t find it 🙂

mikerod17:02:33

Yeah, the keyword is translated to a string via name which removes the : char, so you don’t end up finding the :> in the code via a search

mikerod17:02:48

Well, it is in the comment there I guess hah

justinlee17:02:12

i found comment before but i didn’t read carefully enough to realize that this was actually implementing it. i was expecting it to be defined like a normal reagent function/component. it is interesting that it is special cased right into the parsing code

mikerod18:02:51

Yeah, I’m not sure on exactly why other than that is where it needs to handle the native components vs reagent fn style components

justinlee18:02:34

so the :> it isn’t exactly the same as adapt-react-class. :> basically creates an instance of the react component directly, as far as i can tell, whereas adapt-react-class takes the react component and constructs a deftype NativeWrapper from the component. i don’t quite understand if there is any practical difference, though

justinlee18:02:53

actually ignore the previous comment. they both end up as calls to (native-element #js{:name comp} ...)

mikerod18:02:08

@lee.justin.m They are nearly the same thing it seems from the impl. I once thought that there was some sort of runtime performance advantage of using adapt-react-class instead of the inline :> style. However, it isn’t looking much different when looking at the implementation. I could be missing something though.

justinlee18:02:24

yea i don’t think so either. except for the call to adapt-react-class itself, which is trivial, I’m pretty sure there is no difference

justinlee18:02:07

@mikerod do you know who “owns” this project? there is a lot of great documentation on reagent, but I’m trying to understand why it isn’t making its way back into the github project.

mikerod18:02:38

I don’t know.

mikerod18:02:15

https://github.com/reagent-project/reagent/graphs/contributors gives some guesses, but that’s it for what I know.

justinlee18:02:41

i looked at that before. i have this sneaking suspicion that the problem is that this thing is Dan Holmsand’s baby, but he isn’t super involved any more, so now nobody really feels like they own it anymore

mikerod18:02:40

It has had quite a bit of activity on the 0.8 stuff. Seems to be pretty active.

justinlee18:02:19

yea but not by holmsand, who appears to have written most of it

mikerod18:02:02

Yeah, perhaps a change of owners. Idk

gadfly36118:02:20

@lee.justin.m there is truth to Dan being less involved, but the project is being looked after largely by @juhoteperi these days (and also @yogthos @mikethompson)

juhoteperi18:02:04

I'm currently mostly interested about technical improvements (better test runners, getting 0.8 out & improving ClojureScript JS module support), so I haven't mostly looked into updating site or docs

juhoteperi18:02:02

The Re-frame Reagent docs are probably mostly written by @mikethompson? If there is benefit in maintaining them on Reagent repo it should be easy to copy them to wiki, or add to docs folder, which we could later publish as site

juhoteperi18:02:38

If I understand correctly, re-frame wiki docs (where reagent docs are) are legacy and docs/ folder is the new docs?

juhoteperi18:02:07

And if someone is interested in contributing to docs and site, I can accept such pull requests quickly (i.e. no release, no changes to lib code)

gadfly36118:02:52

I might have some time in the coming weeks (i.e., end of February) to take a stab at helping with documentation

justinlee18:02:59

the things I would like to see, and will help with if desired: [1] install a “guide” tab at the top of http://reagent-project.github.io/ right next to the “intro” tab that looks something like this https://purelyfunctional.tv/guide/reagent/. [2] fill out the api docs, which are woefully incomplete. [3] go through the news releases and incorporate every precious nugget of information in there in either the guide or the api, [4] write an interop guide

yogthos18:02:26

I haven't done much work on reagent itself, but I do maintain the templates for it

derpocious20:02:49

hey all, check out this super cool and fantastic reagent + re-frame project that I made!

mikethompson21:02:47

@juhoteperi I'd be very happy to move my various docs across in reagent's /docs. I feel it should have happened already.

mikethompson21:02:04

I think we have to take a "make small wins" approach to the docs.

mikethompson22:02:47

Those three new documents you see used to be in the re-frame Wiki, but they have now been removed from the Wiki and redirected to their new equivalent.