Imran Ali
Imran Ali

Reputation: 91

undefined is not an object (evaluating ' _firebase.firebase.firestore

i want to fetch all data from firestore and show on a list

export const fetchAds = () => {
return dispatch => {
firebase
  .firestore()
  .collection("ads")
  .get()
  .then(ads => {
    dispatch({ type: FETCH_ADS, ads });
  });
 };
};

this is my actions file

import * as actions from "../../actions"; 

class HomeScreen extends Component {

 renderAds() {
return this.props.ads.map((ad, index) => {
  return <Cards key={index} ad={ad} />;
 });
}
  function mapStateToProps(state) {
   return {
     ads: state.ads.data
  };
  }

export default connect(
   mapStateToProps
   )(HomeScreen);

this is my list where i can show it but it show me the error undefined is not an object (evaluating ' _firebase.firebase.firestore

Upvotes: 1

Views: 3552

Answers (1)

samad324
samad324

Reputation: 229

you should have to firestore from firebase package! like:


import firebase from 'firebase'
import 'firebase/firestore';

export const fetchAds = () => {
return dispatch => {
firebase
  .firestore()
  .collection("ads")
  .get()
  .then(ads => {
    dispatch({ type: FETCH_ADS, ads });
  });
 };
};

Upvotes: 2

Related Questions