score:0
The problem is that you set the state before the promise is resolved. Change the code in the following way:
GetCoffeeList() {
coffeeCollection.get().then((querySnapshot) => {
const cups = []
querySnapshot.forEach(function (doc) {
cups.push({ name: doc.id})
});
console.log('Updating state')
console.log(cups)
this.setState({ coffeeList: cups })
console.log('End GetCoffeeList')
})
}
Source: stackoverflow.com
Related Query
- React - Render happening before data is returned and not updating component
- Why is my React component render called twice, once without data and then later with data, but too late exception?
- React router 4 `Link` component only changing the url and not updating the route
- React component not updating on final dispatch and update of redux state
- How to Read image data from API and render in React Component
- How to make my component re render after updating props from selector in react and redux-saga?
- Trying to render Firestore information in React component - utilization of useRef() not re-rendering and useState() raises error
- react component not render new data from redux store
- React functional component is not rendering when updating the Sate after pushing data to array
- Render response data through mapping to a child html element... using React and updating state
- React Changing props of component and not render each time
- React fetch data before render class component
- React Context - Context and Child render are not updating
- React child component not fetching props and updating state
- Fetch data into React component and render it
- React functional component not updating when pushing data to array
- Why my React component handler is executed at render time and will not work afterwhile?
- react component constantly fetching and updating data for no reason
- React Component Not Being Populated even after updating state and executing forEach
- Nothing was returned from render error in React application when embedding a functional component and returning list from there
- React component cannot map and render data in an array from an API
- React native + redux populate store with data before any Component render
- How to fetch data before render functionnal component in react js
- react component does not render and it only appears in inspect section
- React hooks component not updating after map, but see data loading / refreshing with error
- React and Chartjs not updating from dynamic data through api
- How fetch data by api and render child component with it - react google maps
- React State Not Updating on First click and Component Not Rendering
- React - Getting collection from Firebase and updating state to render a child component
- React - Updating parameters for function calls by taking data from one component and passing it to the next is lagging by one step
More Query from same tag
- TextField Unnecessary Re-renders
- HTTP GET response 304 status error after deploying react app on netlify
- I want to add parameters in div element with React
- React/Typescript 2 optional props required together
- React auto generate state from form name value pairs from event.target
- NextJS Track Mounted Components in SSR
- Gatsby graphql resolver query not returning all fields
- Check if the time difference is less than 1 second in moment
- error in implementing seconds countdown using state in react
- How to test child component method without Enzyme?
- How to prevent non-deterministic state updation in Redux?
- TypeError: this.state.employees.map is not a function
- Correct way of Creating multiple stores with mobx and injecting it into to a Component - ReactJs
- braces around params -- why?
- Warning: Functions are not valid as a React child.This may happen if you return a Component instead of <Component /> from render
- react-datetime-range-picker how to change the inner style set from the library
- Material ui DatePicker enable only year
- Render isomorphic React component which requires window object
- google places api text not working in mui TextField
- How to change the font size in the button?
- How to "reference/import" an svg from public folder inside an scss file in src folder?
- Sorting By Asc and Desc date
- Navbar conditional rendering
- Is possible to use react-window for displaying a list of items with buttons?
- Including useContext hook causes child's useState to reset to initial value
- React + Redux + Typescript Chrome Extension Popup Script - Redux Devtools Shows "No Store Found"
- Updating object in array hook react js
- Where does the value count come from in response.json()?
- I want to spyOn method, return value, and continue running through the script
- Error in showing error for openweathermap API