Skip to content

Commit

Permalink
Adds action info to transition
Browse files Browse the repository at this point in the history
  • Loading branch information
jwickens committed Jun 9, 2021
1 parent 44ec859 commit 4d5266a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions build/lib/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ var Redirect = require('./Redirect');
* an instance of this class as their first argument.
*/
function Transition(path, retry) {
var action = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];

this.path = path;
this.abortReason = null;
this.action = action;
// TODO: Change this to router.retryTransition(transition)
this.retry = retry.bind(this);
}
Expand Down
2 changes: 1 addition & 1 deletion build/lib/createRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function createRouter(options) {
toRoutes = nextRoutes;
}

var transition = new Transition(path, Router.replaceWith.bind(Router, path));
var transition = new Transition(path, Router.replaceWith.bind(Router, path), action);
pendingTransition = transition;

var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
Expand Down
5 changes: 4 additions & 1 deletion build/umd/ReactRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,7 @@ return /******/ (function(modules) { // webpackBootstrap
toRoutes = nextRoutes;
}

var transition = new Transition(path, Router.replaceWith.bind(Router, path));
var transition = new Transition(path, Router.replaceWith.bind(Router, path), action);
pendingTransition = transition;

var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
Expand Down Expand Up @@ -3052,8 +3052,11 @@ return /******/ (function(modules) { // webpackBootstrap
* an instance of this class as their first argument.
*/
function Transition(path, retry) {
var action = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];

this.path = path;
this.abortReason = null;
this.action = action;
// TODO: Change this to router.retryTransition(transition)
this.retry = retry.bind(this);
}
Expand Down
4 changes: 2 additions & 2 deletions build/umd/ReactRouter.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion modules/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ var Redirect = require('./Redirect');
* The willTransitionTo and willTransitionFrom handlers receive
* an instance of this class as their first argument.
*/
function Transition(path, retry) {
function Transition(path, retry, action = null) {
this.path = path;
this.abortReason = null;
this.action = action;
// TODO: Change this to router.retryTransition(transition)
this.retry = retry.bind(this);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/createRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function createRouter(options) {
toRoutes = nextRoutes;
}

var transition = new Transition(path, Router.replaceWith.bind(Router, path));
var transition = new Transition(path, Router.replaceWith.bind(Router, path), action);
pendingTransition = transition;

var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
Expand Down

0 comments on commit 4d5266a

Please sign in to comment.