#web-components

9 bookmarks tagged with #web-components · RSS Feed · ← All Tags

Web component gotcha: constructor vs connectedCallback | Read the Tea Leaves

https://nolanlawson.com/2024/01/13/web-component-gotcha-constructor-vs-connectedcallback/
A common mistake I see in web components is this: This setupLogic() can be just about anything – subscribing to a store, setting up event listeners, etc. The teardownLogic() is designed to undo those things – unsubscribe from a store, remove event listeners, etc. The problem is that constructor is called once, when the component…