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

Prompt doesn't work if "message" function is async #6669

Closed
PetrivskyiTaras opened this issue Mar 27, 2019 · 2 comments
Closed

Prompt doesn't work if "message" function is async #6669

PetrivskyiTaras opened this issue Mar 27, 2019 · 2 comments

Comments

@PetrivskyiTaras
Copy link

Hi, I use react-router-dom v4.2.2

Prompt takes an argument "message" and it can be a function but if this function is async it doesn't work. Why? Some times it is very useful.

Are you plan to add this possibility?

I need it for data validation with a request to the backend. If validation is successful I can allow the transition from the current page.

Thanks for your contribution!

Prompt

@timdorr
Copy link
Member

timdorr commented Mar 27, 2019

Because we need to respond synchronously to block the transition. We can't delay it for an async request to resolve. Also, this will lead to a bad UX, as there would be nothing presented to the user to represent progress or a loading state while the request resolves. It would be better to block this earlier in the lifecycle, before you navigate.

@timdorr timdorr closed this as completed Mar 27, 2019
@PetrivskyiTaras
Copy link
Author

Tim, thanks for the clear answer!
Try to found another solution.

@lock lock bot locked as resolved and limited conversation to collaborators May 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants