Skip to content

Commit

Permalink
[1.0] Fix gatsby-link for undefined nextState (#907)
Browse files Browse the repository at this point in the history
* Fix gatsby-link for undefined nextState

* Solves an error if `/route/child/` is available but `/route/` is not.

* Strip debug code
  • Loading branch information
0x80 authored and KyleAMathews committed May 3, 2017
1 parent 6f6c61f commit 25dc2f2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/gatsby-link/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const GatsbyLink = createClass({
to: PropTypes.string.isRequired,
},
componentDidMount() {
// Only enable prefetching of Link resources in production and for browsers that
// don't support service workers *cough* Safari/IE *cough*.
// Only enable prefetching of Link resources in production and for browsers
// that don't support service workers *cough* Safari/IE *cough*.
if (
(process.env.NODE_ENV === `production` &&
!(`serviceWorker` in navigator)) ||
Expand All @@ -35,9 +35,13 @@ const GatsbyLink = createClass({
[routes],
createLocation(this.props.to),
(error, nextState) => {
getComponents(nextState, () =>
console.log(`loaded assets for ${this.props.to}`)
)
if (error) {
return console.error(error)
}

if (nextState) {
getComponents(nextState)
}
}
)
}
Expand Down

0 comments on commit 25dc2f2

Please sign in to comment.