Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ComponentRenderer shouldUpdateComponent return true when props c… #3516

Merged
merged 3 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/gatsby/cache-dir/component-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => <div>{children()}</div>

Expand Down Expand Up @@ -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 (
Expand All @@ -117,7 +118,7 @@ class ComponentRenderer extends React.Component {
return true
}

return false
return shallowCompare(this, nextProps, nextState)
}

render() {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down