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

Fixes component-renderer to allow for use of client-only-paths #1542

Merged
merged 2 commits into from Jul 18, 2017

Conversation

scottyeck
Copy link
Contributor

According to #1501, it looks like client-only-paths are broken in 1.0. (It actually looks like this has been broken since v1.0.0-beta.6.)

Looks like componentShouldUpdate assumes that, a route-change should only trigger a re-render if its accompanied by a corresponding change in the higher-level pageResources.component. In theory, this makes sense, though it's directly in conflict with the notion of client-only paths. My thought is that the re-render should be triggered if either the component changes OR the found page has a corresponding matchPath, (as demonstrated in the client-only-paths docs), in which case gatsby may not know whether or not a re-render is necessary and should optimistically trigger one.

If there's a better way to go about this, great. 😎

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 18, 2017

Deploy preview ready!

Built with commit c323826

https://deploy-preview-1542--using-drupal.netlify.com

@KyleAMathews
Copy link
Contributor

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 18, 2017

Deploy preview ready!

Built with commit c323826

https://deploy-preview-1542--gatsbyjs.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 18, 2017

Deploy preview ready!

Built with commit c323826

https://deploy-preview-1542--gatsbygram.netlify.com

@KyleAMathews
Copy link
Contributor

Nice! I liked how tightly scoped the fix is. Don't fix one thing and inadvertently break another (like I did for beta.6 ;-))

@aliaksejenka
Copy link
Contributor

With a current (1.9.67) version of Gatsby I came upon non-working links to the client-only path in production build. I found this thread and discovered the following mismatch between the contents of this fix and the master, in the loader.js:

  ...
  const done = () => {
    if (component && json && (!page.layoutComponentChunkName || layout)) {
      pathScriptsCache[path] = { component, json, layout } <<< here missing the "page" member
      const pageResources = { component, json, layout } <<< and here too

After I added that "page" member, links began to work. Maybe at some point it was overwritten with a "layout" by mistake?

@KyleAMathews
Copy link
Contributor

@skorowarkin someone else was mentioning that this was broken — could you submit a PR with the fix!?

@aliaksejenka
Copy link
Contributor

@KyleAMathews done: #2506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants