Skip to content

useAnalytics missing in ReactFire v4 #429

@jhuleatt

Description

@jhuleatt

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 #428 (reply in thread)


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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions