diff --git a/modules/TransitionUtils.js b/modules/TransitionUtils.js
index 807e316544..a1382a8b5e 100644
--- a/modules/TransitionUtils.js
+++ b/modules/TransitionUtils.js
@@ -82,9 +82,9 @@ export function runEnterHooks(routes, nextState, callback) {
enterHooks.clear()
const hooks = getEnterHooks(routes)
return runTransitionHooks(hooks.length, (index, replace, next) => {
- const wrappedNext = () => {
+ const wrappedNext = (...args) => {
if (enterHooks.has(hooks[index])) {
- next()
+ next(...args)
enterHooks.remove(hooks[index])
}
}
@@ -106,9 +106,9 @@ export function runChangeHooks(routes, state, nextState, callback) {
changeHooks.clear()
const hooks = getChangeHooks(routes)
return runTransitionHooks(hooks.length, (index, replace, next) => {
- const wrappedNext = () => {
+ const wrappedNext = (...args) => {
if (changeHooks.has(hooks[index])) {
- next()
+ next(...args)
changeHooks.remove(hooks[index])
}
}
diff --git a/modules/__tests__/transitionHooks-test.js b/modules/__tests__/transitionHooks-test.js
index e77575d9b5..1e36265b49 100644
--- a/modules/__tests__/transitionHooks-test.js
+++ b/modules/__tests__/transitionHooks-test.js
@@ -6,6 +6,7 @@ import { routerShape } from '../PropTypes'
import execSteps from './execSteps'
import Router from '../Router'
import Route from '../Route'
+import match from '../match'
describe('When a router enters a branch', function () {
let
@@ -397,13 +398,17 @@ describe('Changing location', () => {
cb()
})
}
+ const onEnterError = (state, replace, cb) => {
+ cb(new Error('transition error'))
+ }
const createRoutes = ({ enter, change }) => [
,
,
-
+ ,
+
]
beforeEach(() => {
@@ -443,4 +448,16 @@ describe('Changing location', () => {
})
})
})
+
+ it('should pass error correctly', (done) => {
+ const routes = createRoutes({ enter: true })
+
+ match({ routes, location: '/error' }, (error, redirectLocation, renderProps) => {
+ expect(error).toExist()
+ expect(error.message).toEqual('transition error')
+ expect(redirectLocation).toNotExist()
+ expect(renderProps).toNotExist()
+ done()
+ })
+ })
})