FirebaseExtended / reactfire

Hooks, Context Providers, and Components that make it easy to interact with Firebase.
https://firebaseopensource.com/projects/firebaseextended/reactfire/
MIT License
3.52k stars 401 forks source link

`useAnalytics` missing in ReactFire v4 #429

Closed jhuleatt closed 3 years ago

jhuleatt commented 3 years ago

I used useAnalytics with reactfire 3.x. But when I upgraded to reactfire 4.x, useAnalytics has no exported from reactfire. reactfire 4.x obsoleted useAnalytics module, or have alternative way of useAnalytics module. I could not find the mention of useAnalytics.

Originally posted by @shiiinji in https://github.com/FirebaseExtended/reactfire/discussions/428#discussioncomment-1236734


Temporary workaround: to make your own useAnalytics hook, use Firebase's getAnalytics with ReactFire's useFirebaseApp:

import { getAnalytics } from "firebase/analytics";
import { useFirebaseApp } from "reactfire";

function useAnalytics() {
  const app = useFirebaseApp();
  return getAnalytics(app);
}
shiiinji commented 3 years ago

Thank you for your replying and share the work around of the issue.

jhuleatt commented 3 years ago

fixed in 4.0.1