Skip to content

Commit

Permalink
Set ___history immediately so never undefined fixes #3311 (#3313)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews authored Dec 22, 2017
1 parent 7a5a0e3 commit c1d47bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/gatsby/cache-dir/production-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Router, Route, withRouter, matchPath } from "react-router-dom"
import { ScrollContext } from "gatsby-react-router-scroll"
import domReady from "domready"
import history from "./history"
window.___history = history
import emitter from "./emitter"
window.___emitter = emitter
import pages from "./pages.json"
Expand Down Expand Up @@ -101,9 +102,11 @@ apiRunnerAsync(`onClientEntry`).then(() => {
action: history.action,
})

let initialAttachDone = false
function attachToHistory(history) {
if (!window.___history) {
if (!window.___history || initialAttachDone === false) {
window.___history = history
initialAttachDone = true

history.listen((location, action) => {
if (!maybeRedirect(location.pathname)) {
Expand Down

0 comments on commit c1d47bb

Please sign in to comment.