未定义不是对象(评估'_firebase.firebase.firestore [英] undefined is not an object (evaluating ' _firebase.firebase.firestore

查看:46
本文介绍了未定义不是对象(评估'_firebase.firebase.firestore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从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 });
  });
 };
};

这是我的操作文件

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);

这是我可以在其中显示的列表,但它向我显示未定义的错误不是对象(正在评估'_firebase.firebase.firestore

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

推荐答案

您应该必须从firebase软件包中进行 firestore !像:

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 });
  });
 };
};

这篇关于未定义不是对象(评估'_firebase.firebase.firestore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆