diff --git a/packages/gatsby/cache-dir/component-renderer.js b/packages/gatsby/cache-dir/component-renderer.js index 8b07be5e23eb6..b10749eac5b2a 100644 --- a/packages/gatsby/cache-dir/component-renderer.js +++ b/packages/gatsby/cache-dir/component-renderer.js @@ -3,6 +3,7 @@ import PropTypes from "prop-types" import loader, { publicLoader } from "./loader" import emitter from "./emitter" import { apiRunner } from "./api-runner-browser" +import shallowCompare from "shallow-compare" const DefaultLayout = ({ children }) =>
{children()}
@@ -90,22 +91,22 @@ class ComponentRenderer extends React.Component { if (!nextState.pageResources) { return true } - // Check if the component or json have changed. if (!this.state.pageResources && nextState.pageResources) { return true } - if ( this.state.pageResources.component !== nextState.pageResources.component ) { return true } + if (this.state.pageResources.json !== nextState.pageResources.json) { return true } + // Check if location has changed on a page using internal routing // via matchPath configuration. if ( @@ -117,7 +118,7 @@ class ComponentRenderer extends React.Component { return true } - return false + return shallowCompare(this, nextProps, nextState) } render() { diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index abea5a4100d54..8d8bb641b757c 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -96,6 +96,7 @@ "relay-compiler": "^1.4.1", "remote-redux-devtools": "^0.5.7", "serve": "^6.4.0", + "shallow-compare": "^1.2.2", "sift": "^3.2.6", "signal-exit": "^3.0.2", "slash": "^1.0.0",