gpt4 book ai didi

reactjs - 将 firebase 集成到 React 应用程序时出错

转载 作者:行者123 更新时间:2023-12-02 00:38:11 25 4
gpt4 key购买 nike

我在尝试构建我的 React 应用程序时遇到此错误。自构建失败以来唯一发生变化的是我尝试向应用程序添加一个 firebase 数据库。我正在尝试以我在正在使用的教程中找到的相同方式来实现它。

×
REBASE: Rebase.createClass failed. Expected an initialized firebase or firestore database object.
▶ 3 stack frames were collapsed.
./src/base.js
C:/Dev/React/my-app/src/base.js:3
1 | import Rebase from 're-base';
2 |
> 3 | const base = Rebase.createClass({
4 | apiKey: "AIzaSyC1UGLssKKLkKvYRp02zYVpM1-D88czp7I",
5 | authDomain: "catch-of-the-day-ethan-fie.firebaseapp.com",
6 | databaseURL: "https://catch-of-the-day-ethan-fie.firebaseio.com",

下面来自 base.js 的代码,个人信息和 API key 已编辑:

import Rebase from 're-base';

const base = Rebase.createClass({
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "catch-of-the-day-xxxxx-xxxx.firebaseapp.com",
databaseURL: "https://catch-of-the-day-xxxxx-xxxx.firebaseio.com",
projectId: "catch-of-the-day-xxxxx-xxxx",
storageBucket: "catch-of-the-day-xxxxx-xxxx.appspot.com",
});

export default base;

最佳答案

给你

import Rebase from 're-base'
import firebase from 'firebase'

const config = {
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "catch-of-the-day-xxxxx-xxxx.firebaseapp.com",
databaseURL: "https://catch-of-the-day-xxxxx-xxxx.firebaseio.com",
projectId: "catch-of-the-day-xxxxx-xxxx",
storageBucket: "catch-of-the-day-xxxxx-xxxx.appspot.com",
messagingSenderId: "SOME_MESSAGING_SENDER_ID"
}

const app = firebase.initializeApp(config)
const base = Rebase.createClass(app.database())


export default base;

关于reactjs - 将 firebase 集成到 React 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48435161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com