Last active
May 8, 2019 05:00
-
-
Save SakshamInABox/59a69b707d193997d125a53c77a65e78 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 * as React from 'react'; | |
import {finalURL} from './UserInput'; | |
export default class Weather extends React.Component<{}> { | |
constructor(props) { | |
super(props); | |
this.state = { | |
hits: [], | |
}; | |
} | |
componentDidMount() { | |
fetch(finalURL) | |
.then(response => response.json()) | |
.then(data => this.setState({ hits: data.hits })); | |
} | |
render() { | |
const { hits } = this.state; | |
return ( | |
<ul> | |
{hits.map(hit => ( | |
<div> | |
<p>City: {hit.main}</p> | |
</div> | |
))} | |
</ul> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 20 - Type 'Readonly<{}>' has no property 'hits' and no string index signature.