Skip to content

Enable custom handling of useBlocker #59

@alexandertrefz

Description

@alexandertrefz

Why it is needed?

Currently, if one wants to prevent navigation (because of unsaved changes, for example) Chicane offers the useBlocker hook to do so, this is limited to just a string message that gets used in a native window.confirm call, however.

It would be great to have the opportunity to render our own Dialogs/Modals , instead of just a native dialog that stands out as "unbranded".

Possible implementation

I am imagining an API kind of like this:

useBlocker(isBlocked: boolean, handleBlocker: () -> Promise)

Where a rejected promise prevents the navigation and a resolved promised allows the navigation.

Upon a navigation, if a blocker is registered, call the blockers handler in order, one at a time until the specific handlers promise is settled. If the promise is rejected, don't call the next handler and prevent navigation. If the promise is resolved, call the next handler, or if no handlers are left, navigate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions