Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
108 views
in Technique[技术] by (71.8m points)

javascript - TypeError: _firebase__WEBPACK_IMPORTED_MODULE_9__.default.collection is not a function

Down below is the code where I am getting an error on. This is a WhatsApp clone using react JS and firebase as a server that I am making and I am following the instructions to the teeth but for some reason, I can't fix this annoying bug! I defined db and imported it as you see below but it is still giving me an error. Plz, help! If you need me to clarify or have any other questions please let me know!

enter image description here

import React, { useEffect, useState } from 'react'
import{Avatar, IconButton} from "@material-ui/core";
import DonutLargeIcon from "@material-ui/icons/DonutLarge";
import ChatIcon from "@material-ui/icons/Chat";
import MoreVertIcon from "@material-ui/icons/MoreVert";
import{SearchOutlined} from "@material-ui/icons";
import SidebarChat from "./SidebarChat";
import "./Sidebar.css";
import db from "./firebase";

function Sidebar() {

 const [rooms, setRooms] = useState([]);

useEffect(() => {
 db.collection("rooms").onSnapshot((snapshot) => 
    setRooms(snapshot.docs.map((doc) =>({
            id: doc.id,
            data: doc.data(),
        }))
        )
    );
        }, []);
question from:https://stackoverflow.com/questions/65649184/typeerror-firebase-webpack-imported-module-9-default-collection-is-not-a-fu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...