Created
March 5, 2019 15:52
-
-
Save NickFoden/e5b8a070a268d3044d55fe9ca1c43b24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import client from "../../sanity/api"; | |
import "./avantGarde.scss"; | |
const query = `*[_type == "photos" && categories[]-> title match "Avant*"] { | |
_id, | |
album, | |
"imageUrl": mainImage.asset->url, | |
title | |
}[0...50] | |
`; | |
class AvantGarde extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
photos: [] | |
}; | |
} | |
componentDidMount() { | |
client.fetch(query, {}).then(photos => this.setState({ photos })); | |
} | |
render() { | |
const { photos } = this.state; | |
return ( | |
<div className="album_container"> | |
<ul> | |
{photos.map(photo => ( | |
<li key={photo._id}> | |
<img src={photo.imageUrl} alt={photo.Title} /> | |
</li> | |
))} | |
</ul> | |
</div> | |
); | |
} | |
} | |
export default AvantGarde; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working with Sanity.io back end.