I am currently having an issue with custom elements, I am building some custom stuff to go on an ecommerce website and one of my custom elements is re-rendering itself multiple times.
window.initDealBadge = function(customer) {
class DealBadgeCustomElement extends HTMLElement {
constructor(){
super();
}
connectedCallback(){
console.log("ELEMENT ADDED TO PAGE")
const mountPoint = document.createElement('span');
this.appendChild(mountPoint);
const attrs = [].reduce.call(this.attributes, (memo, attr) => {
memo[attr.name] = attr.value;
return memo;
}, {});
const data = Object.assign({}, attrs);
ReactDOM.render(<DealBadge customer={customer} id={data.id}/>, mountPoint);
}
}
customElements.define('deal-badge', DealBadgeCustomElement);
}
This is my first time working with Custom elements, has anyone came across this issue before?
Thank you