GATSBY: TypeError: Cannot read property ‘includes’ of undefined

I'm having some trouble filtering out images in my portfolio site laid out in this post…

This is the error I keep getting: "TypeError: Cannot read property 'includes' of undefined"

Anyone know why this might be?

Images query:

query {
  images: allFile (
    filter: { ext: { eq: ".jpg" } },
    sort: { order: ASC, fields: [relativePath] }
  )
  {
        edges {
        node {
        fields {
            imgslug
        }
        relativeDirectory
        id
        childImageSharp {
          fixed(width: 100) {
            src
          }
        }
        }
    } 
  }
}

Image display script:

{data.images.edges.filter((node) => node.relativeDirectory.includes(data.images.edges.node.fields.imgslug)).map(image => {
   return (
      <Img key={image.id} fixed={image.childImageSharp.fixed}/>
   )
})}


Read more here: https://stackoverflow.com/questions/64944854/gatsby-typeerror-cannot-read-property-includes-of-undefined

Content Attribution

This content was originally published by xtyboi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: