FirebaseExtended / reactfire

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

Undefined is not an object app[componentName].bind #226

Open alxhotel opened 4 years ago

alxhotel commented 4 years ago

Version info

React: 16.9.0

Firebase: 7.10.0

ReactFire: 2.0.2

Other (e.g. Node, browser, operating system) (if applicable):

Test case

I'm building an app with Expo and React Native. I'm trying to add analytics to the app but I'm having trouble just using the examples of the docs.

When my code gets to:

const analytics = useAnalytics();

An error appears:

undefined is not an object (evaluating 'app[componentName].bind')

This is at this line: https://github.com/FirebaseExtended/reactfire/blob/80b9431ceb7e584f70a52940085f24a5a5b667bd/reactfire/firebaseApp/sdk.tsx#L127

Expected behavior

Working.

Actual behavior

undefined is not an object (evaluating 'app[componentName].bind')
- node_modules/reactfire/cjs/index.js:220:45 in importSDK.then$argument_0
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue
jhuleatt commented 4 years ago

@alxhotel to help us narrow down the issue, can you please try to create a very minimal app with Expo and see if it still has the same problem (and if it does, share the code with us)? Something simple like this: https://stackblitz.com/edit/react-st5s4o

alxhotel commented 4 years ago

Here is an example of what I'm doing: https://codesandbox.io/s/reactfire-bug-dlmjo

If you use that code in an Expo app, it triggers the error mentioned.

jhuleatt commented 4 years ago

Thanks @alxhotel! Will look into this. It may be a problem with the Firebase JS SDK, in which case there may not be much we can do, but we'll give it a shot.

FYI @jamesdaniels

Tibo46 commented 4 years ago

Hi,

I'm getting the same error and i just have a new react project created with CRA and copied / pasted the code example from the readme of reactfire. My package.json dependencies looks like that: "dependencies": { "@firebase/app": "^0.5.4", "@firebase/util": "0.2.40", "@testing-library/jest-dom": "^5.11.5", "@testing-library/react": "^11.1.2", "@testing-library/user-event": "^12.2.2", "firebase": "7.9.1", "react": "0.0.0-experimental-4ead6b530", "react-dom": "0.0.0-experimental-4ead6b530", "react-scripts": "4.0.0", "reactfire": "2.0.0-rc.1", "web-vitals": "^0.2.4" },

Any update on this error?

olawalejuwonm commented 3 years ago

@alxhotel does the library work on expo?