Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase getAnalytics() throws Error: Component analytics has not been registered yet #530

Open
ky28059 opened this issue Jul 22, 2022 · 2 comments

Comments

@ky28059
Copy link

ky28059 commented Jul 22, 2022

Version info

React: 18.2.0

Firebase: 9.9.1

ReactFire: 4.2.1

Node: 16.14.2

Steps to reproduce

I'm trying (again) to port a CRA firebase project to nextjs and firebase/firebase-js-sdk#6019 still exists on the latest versions. To summarize, the same FirebaseProviders component that initializes and returns SDK providers in CRA break when using them in next. I have tried:

  • Reinstalling firebase and reactfire

image

  • Verifying that @firebase/app versions are not mismatched

image

  • Verifying that firebase versions are not mismatched

image

but running npm run dev still gives the same error:

image
image

Expected behavior

const analytics = getAnalytics(firebase);

should not throw an error.

Actual behavior

The line throws the following error:

Error: Component analytics has not been registered yet
    at Provider.initialize (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\@firebase\component\dist\index.cjs.js:262:19)
    at initializeAnalytics (file:///C:/Users/Kevin/OneDrive/Documents/GitHub/watt/client/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:1020:49)
    at getAnalytics (file:///C:/Users/Kevin/OneDrive/Documents/GitHub/watt/client/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:999:12)
    at FirebaseProviders (webpack-internal:///./components/firebase/FirebaseProviders.tsx:27:87)
    at renderWithHooks (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:5731:15)
    at renderElement (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:5946:7)
    at renderNodeDestructiveImpl (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:6104:11)
    at renderNodeDestructive (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:6076:14)
    at renderContextProvider (C:\Users\Kevin\OneDrive\Documents\GitHub\watt\client\node_modules\react-dom\cjs\react-dom-server.browser.development.js:5920:3)
@ky28059
Copy link
Author

ky28059 commented Jul 22, 2022

Also experiencing #490 and #491, if that helps.

@ky28059
Copy link
Author

ky28059 commented Jul 22, 2022

Interestingly, setting experimental.esmExternals to false in next.config.js changes the error to

image

ky28059 added a commit to GunnWATT/watt that referenced this issue Jul 22, 2022
This also turns off analytics and emulators for the time being; see FirebaseExtended/reactfire#530.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant