【发布时间】:2021-12-31 11:39:23
【问题描述】:
您好,我正在尝试向我的网站添加 instagram 供稿,但我找不到使其工作的方法。我以前没有真正使用过这些工具,所以我不太了解它,但它指出了我认为我在 GraphQL 中有提要的地方。现在的问题是我不知道如何显示图像。任何人都可以帮忙吗?
这是一些代码:
import React from "react"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { useStaticQuery, graphql } from "gatsby"
const CapabilityList = () => {
const data = useStaticQuery(graphql`
query InstagramQuery {
allInstagramContent {
edges {
node {
localImage {
childImageSharp {
fixed(width: 200, height: 200) {
...GatsbyImageSharpFixed
}
}
}
}
}
}
}
`)
let arrayOfInstaImages = getImage(data, 'allInstagramContent.edges')
return (
<div style={{ maxWidth: `900px`, marginBottom: `1.45rem`, display: 'flex' }}>
{arrayOfInstaImages.map((item, i) => {
return (
<div key={i} style={{ width: "200px", height: "200px" }}>
<GatsbyImage image={item.node.localImage.childImageSharp.fixed} />
</div>)
})}
</div>
)
}
export default CapabilityList;
这不起作用并显示错误:类型“IGatsbyImageData”上不存在属性“map”。
所以我认为我需要一些其他方式来显示数组中的一些图像。
非常感谢您的每一个帮助!
【问题讨论】:
标签: javascript reactjs graphql gatsby gatsby-image