react sets the state to the result of an api call

Yes, exactly, it’s a fetch, so you gotta wait for the result and set the state only then, so you could do smth like:

componentDidMount() {
    .then((response) => this.setState({ london: response });

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top