Skip to content

Instantly share code, notes, and snippets.

@Chryus
Last active March 12, 2020 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chryus/6013d141bcd047a04b436108738f9f03 to your computer and use it in GitHub Desktop.
Save Chryus/6013d141bcd047a04b436108738f9f03 to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
export default class DataFetcher extends Component {
state = { data: [] };
componentDidMount() {
fetch("https://data.cityofchicago.org/resource/ydr8-5enu.json?")
.then(response => response.json())
.then(data =>
this.setState(() => {
return { data };
})
);
}
render() {
return this.props.render(this.state.data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment