Skip to content

Instantly share code, notes, and snippets.

@NickFoden
Created March 5, 2019 15:52
Show Gist options
  • Save NickFoden/e5b8a070a268d3044d55fe9ca1c43b24 to your computer and use it in GitHub Desktop.
Save NickFoden/e5b8a070a268d3044d55fe9ca1c43b24 to your computer and use it in GitHub Desktop.
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;
@NickFoden
Copy link
Author

Working with Sanity.io back end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment