score:5
Accepted answer
Move this.setState
inside your db callback (if you put it outside it will be executed before the db call have finished)
componentDidMount() {
const db = firebase.firestore();
var turmarkers =[];
db.collection("Markets").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
turmarkers.push(doc.data())
});
this.setState({
mapdata:turmarkers
});
});
}
Source: stackoverflow.com
Related Query
- How to fix the state update in react while getting data from firestore database
- getting error while destructuring the data from react redux. why it is giving error and how to solve this?
- React JS (Form Update Not Working) - How to set state immediately after getting data from API using mapDispatchToProps?
- Cant Update The state after getting data from the input React js
- How to update the state of a sibling component from another sibling or imported component in REACT
- What is the best way to update my react state when data in database changes?
- How do I correctly add data from multiple endpoints called inside useEffect to the state object using React Hooks and Context API?
- How to Map the data that I am getting from ajax React js?
- How to update redux state using a react variable passed up to the component from a child
- React - how to update state from the prop of other library
- How can I get the right data from database with react
- How to update the React State only after a return from API called is completed
- React - how to set state with the data from a resolved promise
- How can I update the value from the database in React
- How to set the data from my API as initial state for my react component?
- How to update React State in Functional Component while fetching data using API
- How do I make an axios request using a route parameter from React Router, then update state based on the response?
- How to set state at the server for data from API using react redux
- how to update object data of the state in react
- React js backend how to get the price_data info from stripe.checkout.session.line_items and push the data into firestore
- How to get the data from firebase realtime database in react js?
- How to instantly update react state after replacing the value from array
- In Next.js, how can I update React Context state with data from getServerSideProps?
- Getting user data from Firestore and saving it to state - React
- Getting an empty array in React while fetching the data from the api
- How to delete a specific item from a complex data structure while preserving the state in React-redux?
- How to store the data in React state after Querying it from GraphQL?
- How to add objects retrieved from fetch request to the state array in React and then update the view?
- How to change active nav color in react js while getting data from an array?
- Mapping inside a map function, while getting the data from the state a of parent component
More Query from same tag
- how can I pass a single argument to a react function that returns a component?
- How do you change starting day of the week wtih Flatpickr?
- React: State is not up-to-date when I unmount component
- Getting error as 'handleChange is not a function' while selecting date in Material UI
- Is there a glideJS event for whenever the active slide changes?
- How to create a download link (PDF) in React
- React handling click outside for multiple elements
- Better way to Get Property Than using Lodash
- How to import/add multiple images as per JSON key value in ReactJS?
- Deploy ExpressJS with React in docker container
- Eliminate race condition in `axios` nested calls
- Graph won't start at zero
- How to pass event and other arguments inside an arrow function in ReactJs
- can't set backgroundImage in react?
- Google SignIn from Reactive Native giving TypeError - Expo
- How to make a ReactJS app active/visible on AWS
- React: 'p' is not defined no-undef in component file
- Material UI Grid List item Spacing
- React JS: Upload Multiple Files
- react-dnd: drag out a line
- React useState hook - component is rendered twice
- How can I collapse a Bootstrap React Navbar after clicking on a link?
- Jest not creating snapshot or failing tests
- React onClick and onTouchStart fired simultaneously
- Nested Routes in REACT ROUTER DOM, wrapping Components in Router
- My React Component is rendering twice because of Strict Mode
- How to make HTTP request to upload file from reactjs to google drive?
- Reactjs How i can pass props from index.html to App component with Typescript
- React: how to update a deep property?
- How to conditionally render wrapping components in React Router 4/5