Skip to content

Commit

Permalink
fix: route update hook gets current location from listener (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
adjohnson916 authored and KyleAMathews committed Jul 5, 2016
1 parent 364a549 commit 50f72e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/utils/web-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function loadConfig (cb) {
return cb()
}

let currentLocation = null

browserHistory.listen(location => {
currentLocation = location
if (onRouteChange) {
console.warn('onRouteChange is now deprecated and will be removed in the next major Gatsby release (0.12). Please use onRouteUpdate instead. See the PR for more info (https://github.com/gatsbyjs/gatsby/pull/321).')
onRouteChange(location)
Expand All @@ -25,8 +28,7 @@ browserHistory.listen(location => {

function onUpdate () {
if (onRouteUpdate) {
const location = browserHistory.getCurrentLocation()
onRouteUpdate(location)
onRouteUpdate(currentLocation)
}
}

Expand Down

0 comments on commit 50f72e4

Please sign in to comment.