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.
Source: stackoverflow.com
Related Query
- Geocoding a React state property using Google Maps Geocoding API
- React google-maps-react, Change property of hidden div from google maps api
- SetPosition: not a LatLng or LatLngLiteral: in property lat: not a number using React and Google Maps
- How put FusionTablesLayer in Google Maps API using React JS?
- React state property undefined in function component using Context API
- Create DOMNode to pass to google maps API using React or jQuery
- Using Google Place Autocomplete API in React
- How to load the google maps api <script> in my react app only when it is required?
- State using React Typescript: Property does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes
- How to implement Google Maps JS API in React without an external library?
- Custom Overlays for Google Maps v3 using React
- React Google Maps API Autocomplete suggestions are behind the Dialog
- React google maps re-render issue using onBoundsChanged
- React Google Maps Api :Cannot read properties of undefined reading 'emit'
- How to Assign react redux state api get data using axios
- Using class property to set initial state in React
- Property does not exist on state - Using React Router Hooks with TypeScript
- cannot read property of null using state in react
- How to get the state updated of input field of google map api in React app
- React jest testing Google Maps Api , Uncaught TypeError: this.autocomplete.addListener is not a function
- React Google maps API initMap not a function, no packages
- Cannot read property 'maps' of undefined - Google Maps - React JS
- React Google Map and React Places Auto Complete: You have included the Google Maps JavaScript API multiple times on this page
- How do I access a Map object using React Google Maps API?
- Is there a way to import the Google Maps API into react without a script tag?
- Sharing state across React router v6 routes using Context API
- update react child component's state using props received from an async api call made in the parent component
- React jest testing. Cannot read property 'maps' of undefined with google js api
- Get new location and radius from Circle component in React Google Maps API
- React components not rendering from global state using context API
More Query from same tag
- How to convert Array of string to List of string in react js
- Find the time duration/length of an audio file uploaded to a React application
- why I'm not getting the actual state with redux?
- Display a specific user by _id (MongoDB, Node, React) error: Cast to ObjectId failed for value "undefined" at path "_id" for model "user"
- CSS styling on relative divs inside absolute div, height not taking
- Updating states from input field when using React-Redux
- Node js, converting Json data into Html format
- Focus on next Input field on Enter in Redux Form
- Not getting proper output after clicking on Switch Name button in ReactJs
- Antd Select showing "No Data" after search, even thou options are populated
- remove default visibilty icon from outlineinput material ui
- How to use handle 404 error with react-router on django projects
- How to make a conditionally recursive function return (null) in ReactJS?
- Calling redux-form dispatch(change) from within a redux-saga
- key value mapping with array object
- How to get URL segment in react.js
- How to reset to initial state after using filter() on an array in React.js?
- React, Keep getting Cannot read property 'value' of undefined on Search Input
- How do i make 'useState' transition smoother using Tailwind CSS
- Express + Webpack error after page reload
- How do you use Library Constructer outside of a useEffect hook?
- Editable Table data and updating state in React
- react-router-dom direct access to child path
- How to type any param with React Typescript in Functional Component
- useReducer dispatch executing twice
- gutenburg run js function on post save
- Embed Calendly into React
- How to add an onClick event to a variable outside my class extends?
- Polling API every x seconds with react
- Docker stuck at npm install