This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-11
Channels
- # announcements (1)
- # asami (10)
- # aws (36)
- # babashka (1)
- # beginners (32)
- # biff (13)
- # calva (2)
- # cider (2)
- # clj-kondo (3)
- # cljs-dev (5)
- # clojure-poland (2)
- # clojured (5)
- # clojurescript (7)
- # core-logic (13)
- # core-matrix (2)
- # core-typed (1)
- # datomic (1)
- # fulcro (19)
- # gratitude (6)
- # meander (15)
- # minecraft (4)
- # pathom (3)
- # podcasts-discuss (2)
- # reagent (19)
- # releases (1)
- # shadow-cljs (69)
- # sql (3)
- # tools-deps (22)
- # vim (1)
I need some help rendering a web component using reagent. This works:
[:div
{:dangerouslySetInnerHTML
{:__html "<youtube-video src=''>"}}]
But this does not work:
[:youtube-video {:src ""}]
In the second example, It seems that the web component attributes are empty when the class is constructed.No, but if I put a breakpoint in the constructor, the element seems to have no attributes:
class o extends HTMLElement {
constructor() {
super(), this.attachShadow({
mode: "open"
}), this.shadowRoot.appendChild(e.content.cloneNode(!0));
const t = this.getAttribute("src");
// HERE t is null, and this.outerHTML is "<youtube-video></youtube-video>"
this.onPlayerReadyQueue = [], t && this.load();
}
Interesting. There are a couple of open issues in Reagent's bug tracker about allowing custom elements.
Seems like in the mean time, you can either keep on using :dangerouslySetInnerHTML
or use JS interop with React to directly create a React element.
Thanks. It's strange, because the final html renders as <youtube-video src="
It must be something to do with reagent creating the element and then setting the attributes instead of creating it in one go.
Got it - it was more a react problem than a reagent problem. This seems to be working now:
[:youtube-video {:src ""
:ref #(when % (.load %))}]
Ah, so then custom elements are supported..? I haven't read those issues thoroughly, maybe there are some aspects of them that don't work that well.
BTW you should add ^js
in front of that %
to avoid potential externs issues with .load
.
Also, could rewrite it as #(some-> ^js % .load)
.
Any one know how to handle these ? using fe-blend does not work, do these need to be added into reagent as supported nodes to silence the warnings I get the same for turbulence ?
Warning: <feBlend /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements
nope straight up reagent but the nodes above are embeded svg nodes, most work fine but those do not, probably others as well, but those are the ones I am aware of at the moment
yeah that's what I tried it stops blending though, if I use :feBlend it works I just get the warning
[:feTurbulence {:type "turbulence" :base-frequency "0.05" :num-octaves "3" :result "turbulence"}]
this works with warnings
[:fe-turbulence {:type "turbulence" :base-frequency "0.05" :num-octaves "3" :result "turbulence"}]
this how ever does not work at all for mesame for :feDisplacementMap and :feBlend
^17.0.2 I had not considered it may have been a react issue, I will explore that avenue I figured it was more a hiccup to react conversion thing.