Cannot read properties of null #34274
-
I am getting this error when I run
The problem lies in my blog post template
If I remove |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 7 replies
-
Here is a link to my |
Beta Was this translation helpful? Give feedback.
-
This only gets more and more confusing. I deleted
I do not have a
|
Beta Was this translation helpful? Give feedback.
-
Referencing this issue #4103 |
Beta Was this translation helpful? Give feedback.
-
First, I'll suggest you to prevent the error by testing value of Here as exemple : const BlogPostPage = ({ data, pageContext, location }) => {
const post = data.mdx
const { previous, next } = pageContext
if(!post) return <pre>{JSON.stringify(pageContext,null,2)}</pre>
return // ... your code
} This code will print the |
Beta Was this translation helpful? Give feedback.
-
@violy - that is a very handy trick. Thank you 👍🏼 😄 I added the code and after running
My first thought was that my query in
However, I am still getting the same read out when I navigate to the blog post... What am I missing? |
Beta Was this translation helpful? Give feedback.
-
Is your Querying your data via pageContext don't change anything if the data is in failure (missing, whatever…) — you should continue to use page query instead of pageContext querying. |
Beta Was this translation helpful? Give feedback.
-
My
I have tried Odly enough the error messages changed this afternoon at random. Now it says:
and
I am not understanding what you mean when you say
Could you clarify please? Thank you for your help in debugging this, I very much appreciate it. |
Beta Was this translation helpful? Give feedback.
-
what append if you put the same query (filtred on your post slug) on graphQLi interface ? |
Beta Was this translation helpful? Give feedback.
-
If I run the query in GraphiQL
I get this:
|
Beta Was this translation helpful? Give feedback.
-
Submitted bug report #34342 |
Beta Was this translation helpful? Give feedback.
-
Use the query ($id: String) {
mdx(id: {eq: $id}) {
frontmatter {
title
}
body
}
}
|
Beta Was this translation helpful? Give feedback.
-
Opened Isaac-Tait/null-gatsby-repo#1 as a fix for your problem. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much @AnilSeervi I was pleasantly surprised to see your pull request with the work you had put into it. I appreciate it greatly 👍🏼 🥇 To summarize: switching to async await was a big step in the Also I was having issues with pagination not working right until I moved my blog post template out of |
Beta Was this translation helpful? Give feedback.
Opened Isaac-Tait/null-gatsby-repo#1 as a fix for your problem.