Skip to content

Commit

Permalink
👌 add PreventExitListenerResult to export
Browse files Browse the repository at this point in the history
  • Loading branch information
arunachalam-monk committed Jul 17, 2024
1 parent e29a689 commit b9537e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/PreventExit/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo } from 'react';
import { createPreventExitListener } from './store';
import { PreventExitListenerResult, createPreventExitListener } from './store';

/**
* Custom hook that allows preventing the user from exiting the page or navigating away.
Expand All @@ -16,7 +16,7 @@ import { createPreventExitListener } from './store';
*/
export function usePreventExit(
preventExit: boolean,
): Pick<ReturnType<typeof createPreventExitListener>, 'allowRedirect'> {
): Pick<PreventExitListenerResult, 'allowRedirect'> {
const { cleanup, setPreventExit, allowRedirect } = useMemo(createPreventExitListener, []);
useEffect(() => setPreventExit(preventExit), [preventExit]);
useEffect(() => cleanup, []);
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/PreventExit/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function publish(id: symbol, preventExit: boolean) {
};
}

interface PreventExitListenerResult {
/**
* Returns a listener which can used to calculate the state of prevent exit
*/
export interface PreventExitListenerResult {
/**
* Callback used to set the value indicating if direct exit of the page is currently allowed or not.
*/
Expand Down

0 comments on commit b9537e8

Please sign in to comment.