CSFrequency / react-firebase-hooks

React Hooks for Firebase.
Apache License 2.0
3.55k stars 304 forks source link

Compatibility With firebase/compat #250

Closed Yey007 closed 1 year ago

Yey007 commented 2 years ago

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!

Yey007 commented 2 years ago

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.

chrisbianca commented 1 year ago

@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!