-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Props don't get applied on some divs when using gatsby-plugin-offline #6059
Comments
Is it that props aren't applied or is that the css isn't loaded? |
Props are not applied at all. It does not get the |
I think this might be related to #5136. I noticed that when I uninstall the offline plugin, the issue is cleared up and classNames are applied. Note that className is still visible in React using the React Developer Tools plugin. But after refresh it doesn't show up on the rendered code. |
@anthkris yep, seems to be the exact same issue. |
I think this might've been fixed in #7355. Seems resolved for me, anyway. Can someone else confirm? |
@wKovacs64 ah yes, I noticed this problem while working on the PR - I think this is actually a bug in React, since as @anthkris said the className is still applied in the VDOM - also, for me the bug only happened in Chrome (or other Blink-based). I worked around it just by changing the offline shell element to a span - it seems to only occur when the page's outer element is the same as the offline shell's outer element (usually div). |
@davidbailey00 I am still on Gatsby V1 and deploying with Netlify. How might I fix this for my website? Is the only option right now to upgrade to V2 in beta? |
@davidbailey00 Nice find! I guess it means that using a top-level Is there any other element that could be used which would solve this? Perhaps AppShell could render a Fragment instead? As a side note, though I'm fairly certain that it doesn't actually cause any problems, |
I did a quick search on the react issues, and I think it might be related to these issues:
|
I'll backport the fix to V1 since this particular problem is only a one-line change. There might be some other problems in gatsby-plugin-offline which I fixed in the V2 version, but I think on the whole V1 works well (compared to plugin-offline V2 before my PR, which was quite broken).
Theoretically yes - but I haven't tested this
Good idea - having said that, can fragments themselves be empty? I'm fairly new to React so not sure if this would work (but I'll give it a try)
The span is replaced with whatever the page's top-level actual element is, as soon as it loads - until then, it's empty, so it's always valid HTML. |
@davidbailey00 Thanks so much for your help! |
Oh it works then? 👌 It was just a very tired suggestion from me, thanks a lot for trying it out and opening PRs @davidbailey00 |
Description
Props don't get applied to top level divs when using gatsby-plugin-offline and gatsby-plugin-react-next
The bug manifests on top level divs or divs that are top level inside a Fragment. No props seem to be applied. Other types of elements get props applied as usual.
Steps to reproduce
This repo is based on gatsby-starter-blog:
https://github.com/Maistho/gatsby-offline-react-next-issue/commit/a9e6bbc7d0df4de28707a5a2ca0e0eae2a1785ae
Download the repo and run
Then open up the browser on a blog post and reload the page. Make sure that service workers are not deactivated.
Expected result
Props should be applied
Actual result
Props are not applied
Environment
Not sure why, but I get some TypeErros when running gatsby info
File contents (if changed)
The text was updated successfully, but these errors were encountered: