Skip to content

Instantly share code, notes, and snippets.

@SakshamInABox
Last active May 8, 2019 05:00
Show Gist options
  • Save SakshamInABox/59a69b707d193997d125a53c77a65e78 to your computer and use it in GitHub Desktop.
Save SakshamInABox/59a69b707d193997d125a53c77a65e78 to your computer and use it in GitHub Desktop.
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>
);
}
}
@SakshamInABox
Copy link
Author

Line 20 - Type 'Readonly<{}>' has no property 'hits' and no string index signature.

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