score:1

Accepted answer

edit--- scratch that...

you need to wait until you have set a value for this.state.location before you can initialize this.state.address

basically change the fetchrequest to:

fetchapi(url) {
    fetch(url)
      .then((res) => res.json())
      .then((data) => {
        this.setstate({
          avatar: data.avatar_url,
          username: data.login,
          realname: data.name,
          location: data.location,
          followers: data.followers,
          following: data.following,
          repos: data.public_repos,
          address: [your function from the constructor])
        }
      });
  }

and use the data.location instead of the this.state.location, and set the value of address to "" in the constructor.


Related Query

More Query from same tag