-
-
Save Chryus/6013d141bcd047a04b436108738f9f03 to your computer and use it in GitHub Desktop.
This file contains 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"; | |
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