Skip to content

Commit

Permalink
chore(dev-ssr): don't dispatch CREATE_SERVER_VISITED_PAGE if componen…
Browse files Browse the repository at this point in the history
…t is already tracked (#28725)
  • Loading branch information
pieh authored Dec 21, 2020
1 parent 3727947 commit 76a3b57
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/gatsby/src/redux/actions/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,12 @@ actions.removePageData = (id: PageDataRemove) => {
* @param {string} $0.id the chunkName for the page component.
*/
actions.createServerVisitedPage = (chunkName: string) => {
if (store.getState().visitedPages.get(`server`)?.has(chunkName)) {
// we already have given chunk tracked, let's not emit `CREATE_SERVER_VISITED_PAGE`
// action to not cause any additional work
return []
}

return {
type: `CREATE_SERVER_VISITED_PAGE`,
payload: { componentChunkName: chunkName },
Expand Down

0 comments on commit 76a3b57

Please sign in to comment.