Function usePreventLeave

  • Ask for confirmation before leaving the app, like closing the tab or clicking external links. Can only work after the user interacted with the page in any way.

    Example

    const MyComponent = () => {
    const { formState } = useForm();
    usePreventLeave(formState.isDirty);
    return <form />
    }

    Parameters

    • active: boolean

      flag to indicate if the page should be blocked right now

    Returns void

Generated using TypeDoc