簡體   English   中英

找不到變量:firebase

[英]can't find variable : firebase

我正在嘗試將我的 Firestore 與當前用戶相關聯。 一切正常,直到我添加 firebase.auth()。

我有一個錯誤找不到變量:firebase

還有我的 function:

createUser = () => {
      firebase.auth().onAuthStateChanged(function(user) {
        if (user) {
            // User is signed in.
            firestore()
        .collection('Users')
        .add({
            NickName: this.state.NickName,
            Age: this.state.Age,
            City:this.state.City,
            Mail:this.state.Mail,
            MyTeam:[{
                Activity:"",
                City:"",
                Members:[{
                    Mail:"",
                    Pseudo:""
                }],
            Owner:true
            }]
        
            }).then ( ()=>{ }
               
            )
                .then(() => {
                    this.props.navigation.navigate('Profil')
                
                })
                
        } else {
            // No user is signed in.
            console.log('coucou')
        }});
           
                
    }

還有我的進口:

import React, {Component, useState, useEffect} from 'react';



import {
  View,
  Text,
  TouchableOpacity,
  Image,
  TextInput,
  Link,
  SafeAreaView,
  
  Animated,
} from 'react-native';
import auth from '@react-native-firebase/auth';

import { GoogleSignin } from '@react-native-community/google-signin';
import { Button } from 'react-native-ios-kit';
import firestore from  '@react-native-firebase/firestore'

function 在沒有 firebase.auth() 的情況下運行良好,我做錯了什么嗎?

好像你沒有導入 firebase

import * as firebase from 'firebase';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM