Reputation: 1
I'm building my personal portfolio using graphmcms and Gatsby. The project runs perfect in local environment. While running gatsby build it returns
error
Child Component .js (Component where error throws during build )
{
props.images.map((el, idx) => {
return (
<div>
<img src={el.url} alt="img" />
</div>
);
});
}
Parent component.js
//Query
<StaticQuery
query={graphql`
{
Project {
images {
url(transformation: {document: {output: {format: webp}}})
}
}
`}
Child Component
<Child images= {home.images.url} />
Upvotes: 0
Views: 1310
Reputation: 8412
You issue might be laying somewhere else which cause the props.images
to be empty during the initial render
But you could try to check if it's existing first then render it:
{
props?.images && props.images.map((el, idx) => {
return (
<div>
<img src={el.url} alt="img" />
</div>
);
});
}
Upvotes: 1