Skip to content

Instantly share code, notes, and snippets.

@danhollick
Last active October 9, 2018 14:00
Show Gist options
  • Save danhollick/87ece0952f677a579eca26d18eaa0f89 to your computer and use it in GitHub Desktop.
Save danhollick/87ece0952f677a579eca26d18eaa0f89 to your computer and use it in GitHub Desktop.
class App extends Component {
state = { images: [
{ name: '', url:'' }
]}
componentDidMount() {//1
fetch('/frames')//2
.then(res => res.json())//3
.then(data => this.setState({ images: data }))//4
.catch(error => console.log(error));
}
render() {
return (
<div className="App" }>
{this.state.images.map(
(frame,i) =>
<div key={i} >
<img src={frame.url} alt={"figma component"}/>
<p>{frame.name}</p>
</div>
)}
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment