Fork me on GitHub
#reagent
<
2018-02-02
>
joshkh17:02:48

could someone please help me think about the following ReactJS example in a Reagent kind of way? the component seems to have an inherent handle on its children via this.refs. is this possible in Reagent? the only way i know how to get refs is to supply a {:ref fn} property to a child component in the render function. the goal is to store all bounding boxes of children components prior to render, and while i could use jquery i'd prefer to use the reagent way. https://gist.github.com/joshwcomeau/5b0f0f6c9642930d813e#file-atu_2-jsx-L5

joshkh17:02:58

(by its children i mean its children's dom nodes)

justinlee17:02:01

@joshkh you can do ref callbacks just like in normal react by passing something like :ref #(reset! *ref %) to the component

justinlee17:02:37

^ in that example i set the ref to a local atom called *ref

justinlee18:02:11

oh i just looked at the example. i’m puzzled at that this.refs. is that some kind of react feature? I’ve never seen that before

justinlee18:02:02

I think there is something missing from that gist. he must have stored all the children refs on this after initial render