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

Init scripts also on initialClientRender #74

Closed
raae opened this issue Jun 19, 2019 · 4 comments · Fixed by #75
Closed

Init scripts also on initialClientRender #74

raae opened this issue Jun 19, 2019 · 4 comments · Fixed by #75
Assignees
Labels
good first issue Good for newcomers

Comments

@raae
Copy link
Member

raae commented Jun 19, 2019

@adamwiggall made me aware we need to processInstagram and loadTwitter also on onInitalClientLoad.

I would combine processInstagram and loadTwitter in a initScripts function and call that both from both onInitalClientLoad and onRouteUpdate.

The code for this can be found in gatsby-browser.js.

@victornguyen
Copy link
Contributor

In working on this, I've noticed that onRouteUpdate() gets called on the initial page load anyway?

I've PR'ed up the change anyway in case making use of onInitialClientRender() solves something else I'm not aware of. The option is yours 😄

@raae
Copy link
Member Author

raae commented Jul 14, 2019

I created a contentful project using their starter to test something else. And there I found that onRouteUpdate() and onInitialClientRender() is called before the page templates render.

I think this kind of issue prompted this proposed solution. But it does not fix it as both are called prematurely. I cannot figure out why this is the case and what is causing it. A hack is to let onInitialClientRender() call initScript() after a timeout, but that is very hacky.

@raae
Copy link
Member Author

raae commented Jul 14, 2019

Sorry, this only happened in dev mode, not when building and serving.

@adamwiggall can you remember what caused us to believe we had to also init scripts on onInitialClientRender().

@adamwiggall
Copy link

@raae I’m pretty sure when we visited a page using oembed with a clean cache embeds didn’t render. Refreshing the page made them render.

@raae raae closed this as completed in #75 Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants