stenciljs

Stenciljs Intercepting the removal of a component if the user does not confirm


I am developing a web app with stenciljs version 2.19.0. In my application, each page is a stencil component. I need to ensure that on certain pages, the exit (and therefore the component change) is intercepted with a modal that asks the user for confirmation if they really want to exit or not. How can I achieve this? I have checked the lifecycle of components https://stenciljs.com/docs/component-lifecycle and I saw that the disconnected callback is called when the component has already been removed. I don't see any other ways to intercept the exit from a component.

Is it possible to achieve the result I want using the stenciljs lifecycle?


Solution

  • Is it possible to achieve the result I want using the stenciljs lifecycle?

    No - the Stencil lifecycle disconnected callback cannot be used to prevent removal of a component. This is a navigation issue - you want to stop navigation not component removal.