react-webcomponent | projects automates the wrapping of a React component | Frontend Utils library
kandi X-RAY | react-webcomponent Summary
kandi X-RAY | react-webcomponent Summary
This projects automates the wrapping of a React component in a CustomElement.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-webcomponent
react-webcomponent Key Features
react-webcomponent Examples and Code Snippets
Community Discussions
Trending Discussions on react-webcomponent
QUESTION
I have a web component like this
...ANSWER
Answered 2017-Aug-07 at 14:29From what I understand, as of now,
you do not have event listeners for
onload
of the dom in your shadow rootwhen you define a custom element, you can have a
connectedCallback
which is called when you attach an element to your DOM
from what you are trying, it seems to me, that you are trying to ascertain, the exact time when your shadow DOM loads its internal scripts
from what I know, scripts are not scoped to your element, and are global.
So Instead of trying to do what you are doing at the moment which is,
- querying the shadow Root's DOM structure, collecting the script tags and attaching an onload,
you can simply slap an onload to the tags which work like they always have.
Further, you might be interested in mutation observers
if you may want to observe for changes to your shadow DOM, once it is attached
and beyond.
AFAIK, you can not observe DOM changes while you are constructing your element itself / before it is attached
Or, if you are defining your elements in a different file and prefer using HTML Imports
to import them onto the document,
you can use the webcomponentsready
listener from the document that imports, which fires when all the DOM is imported, parsed, and loaded
If there is indeed a way to observe the DOM or listen to template attachments to your element, I would also like to know.
Also, Since you are trying to embed your react app into the custom element, which is probably why you had this question of knowing when to call the loadreactapp
function, you may want to consider using slots
in your shadow DOM, which open up places where you may distribute content after your element has been registered on the browser
Just add your apps or other custom elements, by passing in the attribute slot=
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-webcomponent
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page