0

I want to connect my realtime database in firebase with react by this instruction https://react-firebase-js.com/docs/react-firebase-realtime-database/getting-started

But when I use the "FirebaseDatabaseNode" I'm getting this error.

I already successfully implement the authentication with this plugin.

My app.js


import './App.css';
import firebase from "firebase/app";
import "firebase/auth";
import Home from './components/Home';
import React from 'react';
import Login from './components/login/Login';
import { FirebaseAuthConsumer, FirebaseAuthProvider } from '@react-firebase/auth';
import { FirebaseDatabaseProvider, FirebaseDatabaseNode } from "@react-firebase/database";
function App() {
  let _firebaseConfig = {
    apiKey: "My apiKey",
    authDomain: "my authDomain",
    databaseURL: "my databaseURL",
    projectId: "my projectid",
    storageBucket: "my storageBucket",
    messagingSenderId: "my messagingSenderId",
    appId: "my appId",
    measurementId: "my measurementId"
  };
  return (
    <FirebaseAuthProvider firebase={firebase} {..._firebaseConfig}>
      {
        <FirebaseDatabaseProvider firebase={firebase} {..._firebaseConfig}>
          <FirebaseDatabaseNode
            path="exchange_rate/"
          // limitToFirst={this.state.limit}
          // orderByKey
          // orderByValue={"created_on"}
          >
            {d => {
              return (
                <React.Fragment>
                  <pre>Path {d.path}</pre>
                  <pre style={{ height: 300, overflow: "auto" }}>
                    Value {(d.value)}
                  </pre>
                </React.Fragment>
              );
            }}
          </FirebaseDatabaseNode>
        </FirebaseDatabaseProvider>
      }
    </FirebaseAuthProvider>

  );
}

export default App;

1 Answer 1

2

try importing the database module itself

import "firebase/database"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.