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: react-router-redux ignores custom getUserConfirmation #5286

Closed
bummzack opened this issue Jun 27, 2017 · 5 comments
Closed

Bug: react-router-redux ignores custom getUserConfirmation #5286

bummzack opened this issue Jun 27, 2017 · 5 comments

Comments

@bummzack
Copy link

Version

react-router: 4.1.1
react-router-redux: 5.0.0-alpha.6

Test Case

https://codepen.io/anon/pen/gRXzMg

With the above test-case, navigate to "Prompt", enter something into the input-field and then navigate to "Home". The confirm dialog should read "THIS IS A CUSTOM MESSAGE", but it doesn't.

Steps to reproduce

Set the getUserConfirmation on the ConnectedRouter to be something different than the default behavior.
Trigger a confirmation via Prompt component, instead of the custom getUserConfirmation function, the default implementation will always be called.

Expected Behavior

The ConnectedRouter should also use the custom getUserConfirmation instead of the default implementation.

Actual Behavior

The default implementation (eg. using window.confirm) is used, even when getUserConfirmation is set.

@timdorr
Copy link
Member

timdorr commented Jun 28, 2017

getUserConfirmation is actually a history API. We just pass through to the history creation function. Since you're making your own history instance, you can just pass it in to that: https://github.com/ReactTraining/history#customizing-the-confirm-dialog

@timdorr timdorr closed this as completed Jun 28, 2017
@bummzack
Copy link
Author

Oh, I wasn't aware of that. Thanks for the heads-up!

@amanmehta25
Copy link

@bummzack did this custom getUserConfirmation work for you?

@bummzack
Copy link
Author

bummzack commented Jan 5, 2018

@amanmehta25 I found getUserConfirmation to be lacking. Several people figured out a solution that uses history.block instead. You can find it here, it has even been turned into a package: #4635 (comment)

@amanmehta25
Copy link

Thanks a lot, @bummzack. That really worked for me.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 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

3 participants