CSFrequency / react-firebase-hooks

React Hooks for Firebase.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility With firebase/compat

Yey007 opened this issue · comments

Hello!

First of all, thank you for this library. It has been extremely helpful in developing with Firebase.

I have recently run into a problem while upgrading to v5 that uses the version 9 modular SDK. Firebase promises that version 8 code and version 9 code should be interoperable, even within the same product. However, the type definitions for this library don't seem to allow for this interoperability. Code similar to the following fails for me at compile time:

import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';

// In component
const doc = firebase.firestore().collection('col').doc('id');
const [...] = useDocument(doc)

Would it be possible to support interoperability? Or is there a barrier that I am not aware of?

Thank you!

P.S.: I am willing to PR this if necessary, just ask!

Update: I was able to refactor quickly, so this isn't an urgent problem. However, I'm still willing to work on this for those with larger codebases.

@Yey007 It's very hard to do this without duplicating the code base and creating a compat version of the hooks. Given the time constraints I have with regards to time on the project, it's not something that I plan on doing, particularly as I'd imagine the window for this to be useful is probably now past. I am very happy to review contributions though!