Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Blocker Function type is misleading #12231

Open
CJHorlebein opened this issue Nov 4, 2024 · 0 comments
Open

[Bug]: Blocker Function type is misleading #12231

CJHorlebein opened this issue Nov 4, 2024 · 0 comments
Labels

Comments

@CJHorlebein
Copy link

What version of React Router are you using?

6.27.0

Steps to Reproduce

  • Set up a BlockerFunction using react-router.
  • Within the function, attempt to access args.currentLocation, args.nextLocation, or args.historyAction.
  • Trigger navigation to an external site or close the browser tab.

Expected Behavior

The BlockerFunction currently expects args to always be provided based on its typing, so developers naturally assume it will be available. However, args is only provided when navigating within the app. Typing args as potentially undefined would allow users to avoid type errors and handle cases where args may not be provided, such as when navigating to an external site or closing the tab.

Actual Behavior

When navigating to an external site or closing the tab, the args object in BlockerFunction is undefined, resulting in runtime errors if properties like currentLocation, nextLocation, or historyAction are accessed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant