Which project does this relate to?
Router
Describe the bug
When using useBlocker with memoryRouter, blocked page is not blocked.
const Component = () => {
useBlocker({
shouldBlockFn: () => true,
});
useEffect(() => {
navigate({ to: '/some-page' });
}, [])
return null;
}
const memoryHistory = createMemoryHistory({
initialEntries: ['/'], // Pass your initial url
});
// Create a new router instance
export const router = createRouter({
routeTree,
scrollRestoration: true,
history: memoryHistory,
});
// Register the router instance for type safety
declare module '@tanstack/react-router' {
interface Register {
router: typeof router;
}
}
export type Router = typeof router;
Your Example Website or App
https://stackblitz.com/edit/github-g3ejtttf
Steps to Reproduce the Bug or Issue
- create memory history
- set router history in createRouter to memoryHistory
- use useBlocker with shouldBlockFn: () => true
- Page navigation is not blocked
Expected behavior
As a user I expected blocked navigation no matter the history I use.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.150.0
- OS: macOd
- Browser: Chrome
- Browser Version: 143.0.7499.193
- Bundler: Vite
- Bundler Version: 7.2.6
Additional context
No response
Which project does this relate to?
Router
Describe the bug
When using
useBlockerwithmemoryRouter, blocked page is not blocked.Your Example Website or App
https://stackblitz.com/edit/github-g3ejtttf
Steps to Reproduce the Bug or Issue
Expected behavior
As a user I expected blocked navigation no matter the history I use.
Screenshots or Videos
No response
Platform
Additional context
No response