Adapt to new history blocking API #1644
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
<Prompt>
component is currently broken, throwing an exception whenever it should prompt, breaking the page.Objective
This PR fixes an exception when using the
<Prompt>
router component. The regression was probably introduced with a95f57e, when thehistory
dependency was updated to v5.x.This version change came with a breaking change of the
history.block()
API that is used to block transitions between pages (i.e. the sole purpose of the<Prompt>
component).The v5 API requires the parameter of
history.block(...)
to be a function, whereas older versions also accepted a string.See the documentation of the history project: Blocking Transitions (v4) vs Blocking Transitions (v5)
This PR uses the suggested code from the history project to restore the functionality as it was before.
How to test
I am not sure how this can be tested automatically. If anyone can give me a hint I'm happy to add a test.
It can easily be verified manually though:
<Prompt>
component to the 'About' page of the inferno-router-demo (like that)