helix 2021-02-25

@esp1 I think useRef is your friend.

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

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

👍 1
☝️ 1

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

What does the future version look like? 😂

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

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

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.

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

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

☝️ 2

oh nice! i didn't know that