I'm trying to use firebase on a React application for the first time, and I can't really find the right procedure in the documentation.
That is my config.js for firebase (Of course here I have hidden my credentials )
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "*************************",
authDomain: "****************",
databaseURL: "**********************",
projectId: "**********",
storageBucket: "***************",
messagingSenderId: "************",
appId: "***************",
measurementId: "***********"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
export default app;
in my file App.js i have this :
import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router';
import "./App.css";
import Message from "./components/Message";
import MessageEditor from "./components/MessageEditor";
import firebase from './config'
function App(){
const [messages, setMessages] = useState({});
const [pseudo, setPseudo] = useState(useParams().pseudo)
useEffect(()=> {
firebase.syncState('/', {
context: this,
state: 'messages'
})
})
}
Among the errors I get, one tells me that syncState is not a function!