Firebase v9模块化-无法找到变量:IDBIndex

原学程将引见Firebase v九模块化-没法找到变质:IDBIndex的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。

Firebase v9模块化-无法找到变量:IDBIndex 教程 第1张

成绩描写

我正在应用Reaction Native以及EXPO,我正在测验考试应用Firebase V九(模块化版原)。每一当我测验考试在设置装备摆设文件以外应用Firebase函数时,我都邑碰到毛病。比方,我在Firebase.tsx中有signUpWithEmail函数,但是当我测验考试在我的SignUpScreen.tsx中应用它时,它会给我1个

仿佛与我的节面模块有闭??
能够是毛病的版原?
我也出有开用Google Analytics。

以下是我的代码文件:

Firestore.ts:

import { initializeApp } from 'firebase/app';
import { createUserWithEmailAndPassword, getAuth } from 'firebase/auth';
import Constants from 'expo-constants';

const firebaseConfig = {
  apiKey: Constants.manifest?.extra?.firebaseApiKey,
  authDomain: Constants.manifest?.extra?.firebaseAuthDomain,
  projectId: Constants.manifest?.extra?.firebaseProjectId,
  storageBucket: Constants.manifest?.extra?.firebaseStorageBucket,
  messagingSenderId: Constants.manifest?.extra?.firebaseMessagingSenderId,
  appId: Constants.manifest?.extra?.firebaseAppId,
};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

// AUTHENTICATION // ---------------------------------------------------------
export const signUpWithEmail = async (fName: string, lName: string, email: string, password: string) => {
 try {
  await createUserWithEmailAndPassword(auth, email, password);
  console.log('Success!')
 } catch (e) {
  console.log(e);
 }
}

SignUpScreen.tsx:

import React, { useState } from 'react';
import { StyleSheet, View} from 'react-native';
import MyButton from '../components/MyButton';
import MyField from '../components/MyField';
import { signUpWithEmail } from '../services/firebase';


export default function SignUpScreen() {
  const [fName, setFName] = useState("");
  const [lName, setLName] = useState("");
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");

  return (
 <View style={styles.container}>
  <MyField title='First Name' type='text' onChangeFn={setFName}/>
  <MyField title='Last Name' type='text' onChangeFn={setLName}/>
  <MyField title='Email' type='text' onChangeFn={setEmail}/>
  <MyField title='Password' type='text' onChangeFn={setPassword}/>
  <MyButton text="Sign Up" type="primary" size="large" onPressFn={
 () => { signUpWithEmail(fName, lName, email, password) }} />
 </View>
  );
}

const styles = StyleSheet.create({
  container: {
 flex: 一,
 backgroundColor: '#fff',
 alignItems: 'center',
 justifyContent: 'center',
  },
  fixToText: {
 flexDirection: 'column',
 justifyContent: 'space-between',
 alignItems: 'center',
  },
});

以下是我运转运用法式时的毛病:

ReferenceError:没法找到变质:IDBIndex
在申报中的node_modules/react-native/Libraries/Core/ExceptionsManager.js:一0四:六异常
在句柄中的node_modules/react-native/Libraries/Core/ExceptionsManager.js:一七二:一九异常
At node_modules/react-native/Libraries/Core/setUpErrorHandling.js:二四:六 in HandleError
毛病应用中的at node_modules/@react-native/polyfills/error-guard.js:四九:三六。reportFatalError
在GuardedLoadModule中的node_modules/metro-runtime/src/polyfills/require.js:二0四:六
在齐局代码中http://一九二.一六8.一.一8九:一九000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:一四0九四七:三

推举谜底

我很愉快您终究解脱了这个成绩,仿佛Firebase 九版原有1些成绩,我在这里发明了1些成绩https://github.com/expo/expo-cli/issues/三0六六处理计划,根本上是将Firebase版原升级到七或者8。

佳了闭于Firebase v九模块化-没法找到变质:IDBIndex的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。