prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

If no events triggered, unmount error in useFirebaseConnect #1019

Closed adam-remotesocial closed 3 years ago

adam-remotesocial commented 3 years ago

https://github.com/prescottprue/react-redux-firebase/blob/e67bbd71ab25fc4830d881431a1661a93b316efc/src/actions/query.js#L221

For example if I write

useFirebaseConnect(props.alwaysNull && [queryA, queryB])

In this case, unwatchEvents is called on unmount of the component, but events is undefined so events.forEach throws.

Workaround - create a new component to house queries that is only mounted when the query inputs are available.

prescottprue commented 3 years ago

Thanks for reaching out! This is for sure an issue - should be able to be solved by checking for events before calling the forEach

rscotten commented 3 years ago

@prescottprue Could you please respond to #1008?

prescottprue commented 3 years ago

The v3.8.1 release includes a fix for this. Reach out if it isn't working as expected thanks for reporting!

adam-remotesocial commented 3 years ago

Thanks a ton!