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

fix(gatsby): rehydration issue in Dev404Page with DEV_SSR #30581

Merged
merged 3 commits into from
May 3, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Dev404Page extends React.Component {
const initialPagePathSearchTerms = urlState.filter ? urlState.filter : ``

this.state = {
hasMounted: false,
showCustom404: false,
initPagePaths: pagePaths,
pagePathSearchTerms: initialPagePathSearchTerms,
Expand All @@ -32,6 +33,12 @@ class Dev404Page extends React.Component {
this.handleSearchTermChange = this.handleSearchTermChange.bind(this)
}

componentDidMount() {
this.setState({
hasMounted: true,
})
}

showCustom404() {
this.setState({ showCustom404: true })
}
Expand Down Expand Up @@ -78,6 +85,10 @@ class Dev404Page extends React.Component {
}

render() {
if (!this.state.hasMounted) {
return null
}

// Detect when the query returns the default function node that's added when functions
// are *not* enabled. That seems the simplest way to communicate whether
// functions are enabled or not to this page.
Expand Down