-
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
pageContext is not updated when context change #11691
Comments
@RageYL i've picked up on your issue, i've cloned your repo into my machine installed it and did some tests, namelly:
As you can see bellow, the value of My reasoning for this behaviour is that as is, the api hook, either with your object or mine, is on a "fire and forget" mode, it fetches the data once, passes it along and doesn't care about subsequent changes. What you could probably do is on Also three days into Gatsby and already into one api that people tend to struggle more. Congratulations are in order. |
What i find very strange is that everything works fine if there is no query or if i change the query's content (maybe something related to MarkdownRemark resolvers and the cache). Now if i update the data and restart gatsby the change is reflected on the page, but when i update without restarting gatsby, the page still display the same value. So it's already better, but it seems there is still something wrong with the cache. |
Ok, this is bit problematic. There was related fix some time ago - #11048 (which is totally fine). But reason it doesn't work for this use case is that we don't check page contexts between runs (and this is not quite easy to do right now, but doable). In |
I didn't notice you commented while I was writing previous comment
For the most part this is because we try to cache our query results so subsequent runs don't do extra work and re-use cached results. But there are cases where we don't invalidate our cache and you hit one of those. |
Hum, i think i managed to make it work with createPagesStatefully. When the file changed i was deleting the page and then creating it again. So it seems to work correctly with createPagesStatefully: https://github.com/RageYL/gatsby-pageContext/tree/createPagesStatefully. Edit: thinking about it again, it means that when we call Edit2: I just tried what i had on my mind yesterday and it seems to fix the problem: in gatsby/packages/gatsby/src/redux/actions.js Line 298 in d2691a8
I don't have enough experience to know what this update would break. But at least it seems to me that between run, the context is never modified as |
@RageYL this change would cause gatsby to always rerun all queries in bootstrap. |
I think your solution may not work in certain situations: in the first case I Just some thoughts =) Edit: I just removed some statements, this could be solved by what you describe in your first message. Edit 2: after some digging I found one way to solve the problem i just mentioned (i didn't touch anything related to the deletePage)
So I'll stop my digging here :D. I don't know how i can help more about this. If you want my help for something related to this issue, just ask =) |
I'm not sure if i'm allowed to do that, but as yesterday's last edit may provide a solution for the problem, i'm writting a new comment to be sure you get notified. |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m Thanks again for being part of the Gatsby community! |
This was fixed in the meantime. |
Hi,
The issue is not as straightforward as i thought it would be, so here is a repo to reproduce it: https://github.com/RageYL/gatsby-pageContext
And this is different from #6097
I use context from createPage to pass data to a template (I started using gatsby 3 days ago, so not 100% sure if this is the good way), but when the data is updated the pageContext value is not updated.
The pageContext is not updated if:
If you confirm this is indeed an issue, i'm ready to dig in and submit a pull request.
The text was updated successfully, but these errors were encountered: