Following the firebase v9 docs I am trying to implement the onSnapshot to listen to a document change but I keep getting this error.
FirebaseError: Expected type 'Tc', but it was: an object
Here is some simple implementation:
const [channels, setChannels] = useState([]);
useEffect(() => {
const rooms = collection(db, 'rooms');
const unsub = onSnapshot(rooms, (snapshot) => {
setChannels(snapshot.docs.map(doc => ({
id: doc.id,
name: doc.data().name
})))
},
(error) => {
console.log(error)
});
}, []);