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

Static query loads forever when inside a fragment <></> #10016

Closed
TylerBarnes opened this issue Nov 18, 2018 · 3 comments · Fixed by #10443
Closed

Static query loads forever when inside a fragment <></> #10016

TylerBarnes opened this issue Nov 18, 2018 · 3 comments · Fixed by #10443
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@TylerBarnes
Copy link
Contributor

I've seen this on a couple projects now since I use the fragment syntax pretty often. Each time I do it I forget that the fragment is causing the issue but once I delete it or even replace it with a div the static query loads.

I don't have a demo repo to show and it's a fairly minor bug but it should be easy to reproduce.

These work:

<StaticQuery
      query={graphql`
...
`}
render={...}
/>
<div>
<h1>Component title</h1>
<StaticQuery
      query={graphql`
...
`}
render={...}
/>
</div>

This doesn't work and results in the Static query loading message:

<>
<h1>Component title</h1>
<StaticQuery
      query={graphql`
...
`}
render={...}
/>
</>
@jonniebigodes
Copy link

Instead of the shorthand version try it like this:

<React.Fragment>
    <h1>component Title</h1>
    <StaticQuery
      query={graphql`
        ...
      `}
      render={...}
    />
</React.Fragment>

I recreated the issue with the shorthand version and it shows h1 and StaticQuery(loading), but if i use React.Fragment it shows the h1 and also what's inside the render.

@jgierer12 jgierer12 added type: bug An issue or pull request relating to a bug in Gatsby help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. labels Nov 19, 2018
@jgierer12
Copy link
Contributor

This seems to be caused during the query extraction. When starting gatsby develop with it being React.Fragment and later replacing it with the shorthand, it works fine.

@victorandcode
Copy link
Contributor

Hello I've created a PR to address this issue. Please take a look when possible #10443. The explanation of the issue is also there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants