You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I set up my repository to try the example from the docs:
import{graphql}from'gatsby'importReactfrom'react'importGalleryfrom'@browniebroke/gatsby-image-gallery'constMyPage=({ data })=>{constimages=data.allFile.edges.map(({ node })=>node.childImageSharp)// `images` is an array of objects with `thumb` and `full`return<Galleryimages={images}/>}exportconstpageQuery=graphql` query ImagesForGallery { allFile { edges { node { childImageSharp { thumb: gatsbyImageData( width: 270 height: 270 placeholder: BLURRED ) full: gatsbyImageData(layout: FULL_WIDTH) } } } } }`exportdefaultMyPage
And I'm getting the following Typescript error on the line where images is passed into Gallery. It doesn't like that the images array may contain null values, because the images prop is expecting an array of only ImageProp, and the GraphQL query thinks that the nodes may be null. Any suggestions on how to fix this?
Type '({ readonly thumb: IGatsbyImageData; readonly full: IGatsbyImageData; } | null)[]' is not assignable to type 'ImageProp[]'.
Type '{ readonly thumb: IGatsbyImageData; readonly full: IGatsbyImageData; } | null' is not assignable to type 'ImageProp'.
Type 'null' is not assignable to type 'ImageProp'.
The text was updated successfully, but these errors were encountered:
Your suggestion makes sense, we should indeed export our types. Not sure if I'll have time to do it myself, but if you submit a pull request, I'll be more than happy to review it.
Hi, I set up my repository to try the example from the docs:
And I'm getting the following Typescript error on the line where
images
is passed intoGallery
. It doesn't like that the images array may contain null values, because the images prop is expecting an array of only ImageProp, and the GraphQL query thinks that the nodes may be null. Any suggestions on how to fix this?The text was updated successfully, but these errors were encountered: