问题
I have a problem with my gatsby site with graphcms where I can navigate my site just fine by clicking the various links in my site. For example, loading the landing page at /
and then clicking a link to /foo
loads the foo page just fine.
However, if I directly navigate to the /foo
page in my url bar, none of the page's data shows. None of the data that is stored in page-data.json
is showing in the browser.
Seems very similar to:
- Gatsby - page refresh corruption
- GatsbyJS - Blog posts not loading on direct link
$ yarn gatsby --version
yarn run v1.21.1
$ /home/vagrant/apps/agency-studio/ep/ep-website/node_modules/.bin/gatsby --version
Gatsby CLI version: 2.8.28
Gatsby version: 2.19.10
Note: this is the Gatsby version for the site at: /home/vagrant/apps/agency-studio/ep/ep-website
Done in 0.71s.
EDIT #1
This doesn't happen on local (e.g. $ yarn start
). It only happens when I host built files on s3.
EDIT #2
I can reproduce the problem with $ yarn build && yarn serve
回答1:
Another dev on our team found the problem. There's a react bug (nothing gatsby related) issue with using dangerouslySetInnerHTML
on <p>
elements. Works fine with <div>
's though. Go figure...
https://github.com/gatsbyjs/gatsby/issues/11108#issuecomment-455472204
来源:https://stackoverflow.com/questions/60329374/page-data-not-showing-when-directly-navigating-to-page