Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

svelte - Nested component's onMount() not executing imported from external application

We are working a component library that could be used in several of our applications.

This component library has two components:

  • InjectSVG accepts an icon URL. On initial load of the component, it adds an img tag to the DOM and then it fetches the SVG in the onMount lifecycle hook and replaces it with the retrieved SVG contents inline (better for styling, etc).
  • Button accepts text and an optional icon. If present, the icon prefixes the text on the button using the InjectSVG component.

In client applications, when using InjectSVG itself, everything works as expected. However, if we try to use Button, the InjectSVG component renders the original img tag in the DOM, but never executes the onMount callback, so the img tag is never replaced.

An example of the setup can be seen here, but the "error" is not demonstrated because all components are in the "same app". This only occurs when we are trying to import these components into another application and leverage them.

Any suggestions on why this would be happening or where to look?

question from:https://stackoverflow.com/questions/65617208/nested-components-onmount-not-executing-imported-from-external-application

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...