← Home · ↑ May 2024 · Bookmark #104

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

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…
Saved on