Halogen and elements managed by FFI

Hi,

Is there anything I should be aware of while rendering components directly through JS? Let’s say I would like to use some library for charts. I create an empty div somewhere in halogen render function, add an id attribute to it, and handle rendering somehow in a foreign call. How much can it mess with Halogen internals (rendering mechanism, lifecycle actions, no idea)?

Thanks for any input.

1 Like

As long as you don’t move the element around it should be fine. Movement within a parent element will be okay if you’re using keyed elements, but moving it into or out of a container element might cause trouble.

If possible, I’d advise making a component around the empty div, and have the component provides an interface to the FFI stuff via queries. Having the constant element in the component guarantees it won’t be moved around during patching, since the component boundaries delimit DOM patching, and this is the exact scenario that the querying mechanism was made for. :slightly_smiling_face:

2 Likes

That was my idea. Thanks for your advice!