react-firebase-context
react-firebase-context copied to clipboard
without decorators
Howdy, Thanks for the library - it's very useful. It would be more useful, though, if it didn't have decorators, because getting them to work is a pain.
I ended up pulling out the hoc - withFirestore and using auto-bind as follows:
import React, { Component } from 'react'
import autoBind from 'auto-bind'
import { FirestoreContext } from 'react-firebase-context'
const withFirestore = WrappedComponent => {
return class extends Component {
constructor(props) {
super(props)
autoBind.react(this)
}
render() {
return (
<FirestoreContext.Consumer>
{({ firestore, data, query }) => {
firestore.data = data
firestore.query = query
return <WrappedComponent firestore={firestore} {...this.props} />
}}
</FirestoreContext.Consumer>
)
}
}
}
export default withFirestore
and then using it as follows:
export default withFirestore(MyClass)
Hey, thanks for taking the effort submitting the issue and the PR :+1:
I'm not sure if I'm following though, can you send more details on what error you're getting? As far as I can see there shouldn't be anything needing the bind
in the HOC (and decorator usage is 100% optional), but very possible I'm just missing something here :blush:
Hi Julian, I could e wrong - like I said, I'm newer to the react/es6 framework. I remember trying using the firestore as a plain hoc without the decorator in create-react-app and having an error. I'll try it again on monday.
Yeah, not saying you're wrong, very possible that there is an issue. If you could post the error message you're getting would be really helpful :blush:
Hey Julian, from what I read, I can say this is a suggestion to make the library easier to use and it is 'not' a bug or issue report. So there is no error as well. Jim is suggesting you a solution that removes the urge of using decorators. @jim-obrien-orig correct me please if I am wrong.