Fork me on GitHub
#helix
<
2021-02-25
>
ordnungswidrig08:02:16

@esp1 I think useRef is your friend.

(let [containerRef (useRef)]
  (d/div {:id "mycontainer" :ref containerRef}
    ($ ThatMapBoxComponent {:whatever containerRef}))) 

ordnungswidrig08:02:42

But you could just use a fixed id for the container if the Mapbox components is happy with it.

👍 3
☝️ 3
lilactown17:02:55

In current version of helix its helix.hooks/use-ref 🙂

oconn20:02:13

What does the future version look like? 😂

lilactown20:02:34

probably the same 😛 the example above used useRef and I wasn't sure if they were using hx or something

lilactown20:02:56

though I may in a future version move the hooks definitions to helix.core: https://lilac.town/writing/towards-helix-1-0/

oconn23:02:51

That would be nice, even if they just alias the hooks namespace at first. Feel like most of the time I end up importing both.

lilactown17:02:02

You can pass it to DOM elements like above, and also treat the ref like an atom

wilkerlucio17:02:31

also, value of :ref can be a function, that receives the DOM node at the first argument once its mounted

☝️ 6
esp118:02:57

oh nice! i didn't know that