gatsby-source-google-spreadsheet
gatsby-source-google-spreadsheet copied to clipboard
Cannot use in useStaticQuery hook
Hi,
While I can use the plugin in a page level query, I cannot use it in a component level (more specifically using the useStaticQuery method) - returns always 'undefined'.
Is there any example on how to use in a component level query?
Thanks
Hey @dspachos i'm doing this with the following code and it works well 😄
import { useStaticQuery, graphql } from 'gatsby'
export const useZips = () => {
const data = useStaticQuery(
graphql`
query ZipsQuery {
Name1: Sheet1 {
nodes {
attr1
attr2
}
}
Name2: Sheet2 {
nodes {
attr1
attr2
}
}
Name3: Sheet3 {
nodes {
attr1
attr2
}
}
}
`
)
return data
}