Skip to content

Commit c45909a

Browse files
committed
Inline error/abort handling
1 parent 9ccebac commit c45909a

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

modules/components/Routes.js

+5-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var React = require('react');
22
var warning = require('react/lib/warning');
33
var invariant = require('react/lib/invariant');
4-
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
54
var copyProperties = require('react/lib/copyProperties');
65
var HashLocation = require('../locations/HashLocation');
76
var reversedArray = require('../utils/reversedArray');
@@ -261,36 +260,6 @@ function computeHandlerProps(matches, query) {
261260
return props;
262261
}
263262

264-
var BrowserTransitionHandling = {
265-
266-
handleError: function (component, error) {
267-
throw error; // This error probably originated in a transition hook.
268-
},
269-
270-
handleAbort: function (component, reason) {
271-
if (reason instanceof Redirect) {
272-
component.replaceWith(reason.to, reason.params, reason.query);
273-
} else {
274-
component.goBack();
275-
}
276-
}
277-
278-
};
279-
280-
var ServerTransitionHandling = {
281-
282-
handleError: function (component, error) {
283-
// TODO
284-
},
285-
286-
handleAbort: function (component, reason) {
287-
// TODO
288-
}
289-
290-
};
291-
292-
var TransitionHandling = canUseDOM ? BrowserTransitionHandling : ServerTransitionHandling;
293-
294263
var ActiveContext = require('../mixins/ActiveContext');
295264
var LocationContext = require('../mixins/LocationContext');
296265
var RouteContext = require('../mixins/RouteContext');
@@ -348,9 +317,12 @@ var Routes = React.createClass({
348317

349318
this.dispatch(path, actionType, function (error, abortReason) {
350319
if (error) {
351-
TransitionHandling.handleError(this, error);
320+
// Throw so we don't silently swallow errors.
321+
throw error; // This error probably originated in a transition hook.
322+
} else if (abortReason instanceof Redirect) {
323+
this.replaceWith(abortReason.to, abortReason.params, abortReason.query);
352324
} else if (abortReason) {
353-
TransitionHandling.handleAbort(this, abortReason);
325+
this.goBack();
354326
} else {
355327
this.updateScroll(path, actionType);
356328

0 commit comments

Comments
 (0)