dumdom icon indicating copy to clipboard operation
dumdom copied to clipboard

dumdom.inflate/render fails for components without a name

Open 2food opened this issue 2 years ago • 2 comments

Like the title says, not specifying a component name makes inflation fail when doing SSR.

Example: Simple component:

(defcomponent test-div [data]
  [:div (:text data)])

On server side (as part of html string):

(dumdom.string/render (test-div {:text "hello"}))

Then on the client side:

(dumdom.inflate/render (test-div {:text "hello"}) (js/document.getElementById "app"))

dumdom.inflate/render fails with error message "Invalid symbol: /test-div.0.". Setting a name on all the components rendered makes it work, but I assume that it should work for unnamed components as well.

It seems like the auto-generated names like "/test-div.0" fail because of the leading slash. I also observed other cases were the generated name was a uuid, and these failed with the message "invalid number".

2food avatar Jul 20 '23 09:07 2food

It looks like the namespace part is empty. What does the output of (dumdom.string/render (test-div {:text "hello"})) look like on the server side?

cjohansen avatar Jul 22 '23 09:07 cjohansen

Hi! Sorry about the late answer. (dumdom.string/render (test-div {:text "hello"})) Returns: "<div data-dumdom-key=\"&quot;/test-div.0&quot;\">hello</div>"

2food avatar Aug 17 '23 09:08 2food