Skip to content

Commit

Permalink
Adapted to new history blocking API (#1644)
Browse files Browse the repository at this point in the history
* The 'history' project changed the API used to
  block transitions, starting with v5.x.
* Instead of accepting a message string, it now
  requires a callback function that handles the
  browser prompt itself.
  • Loading branch information
fheft authored Jun 16, 2023
1 parent b87ba8e commit 68213f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/inferno-router/src/Prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export class Prompt extends Component<IPromptProps, any> {
this.unblock();
}

this.unblock = this.context.router.history.block(message);
this.unblock = this.context.router.history.block((tx) => {
if (message && window.confirm(message)) {
this.unblock();
tx.retry();
}
});
}

public disable() {
Expand Down

0 comments on commit 68213f0

Please sign in to comment.