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

Could not enter callback of history.block when a page was loaded first #830

Open
fengxinming opened this issue Aug 22, 2020 · 2 comments
Open

Comments

@fengxinming
Copy link

Version

history: 4.10.1

Test Case

https://codesandbox.io/s/billowing-cache-oijj8

Steps to reproduce

Expected Behavior

expect confirmation dialog show up when a page was loaded first

Actual Behavior

@StringEpsilon
Copy link

StringEpsilon commented Aug 22, 2020

As per the docs: The blocking only affects what history can register and properly intercept - and only on the transition between locations. With your particular situation, the initial location is already registered (in createHashHistory) when you activate the block. So history can't know to show the confirmation dialog, because there simply isn't any transition from "no location" to "initial page".

So, you have to prompt the user yourself on initial load.

@fengxinming
Copy link
Author

@StringEpsilon Actually, it is just a demo to show case when a page initial load that can not affect history.block. I was not only to prompt the user on initial load, I wanted to provided navigation guards with history.block and getUserConfirmation, I have finished two guard hooks beforeEach and beforeEnter, but they were not called on on initial load, it because of history.block.

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

No branches or pull requests

2 participants