cjohansen/dumdom

Add function to dumdom.core for rendering "one off"?

augustl opened this issue · 1 comments

Before I make a PR, I just wanted to know what your thoughts are on this :)

I currently do something like this to create an "one off" element:

    (let [drag-el (js/document.createElement "div")
           comp (dumdom.element/inflate-hiccup
                 dumdom.dom/render
                 (my-ns/get-my-comp ...))
          vnode (comp [] 0)]
      (dumdom.core/patch drag-el vnode)
      (.appendChild js/document.body drag-el))

The reason I do this is that I want to render just an element for drag & drop without re-rendering my entire dumdom app on every mousemove. And I do this every time a drag & drop operation is initiated, so I don't want to "pollute" an ever growing current-nodes in dumdom.core by using dumdom/render.

I suppose there are other use cases for rendering an element outside of the "main" dumdom flow as well.

Do you think it makes sense to add this to dumdom.core? Something like (dumdom/render-once [my-comp ...] el)?

Sorry, I completely forgot to respond to this. This sounds good, PR welcome :)