Skip to content

without decorators #1

@jim-obrien-orig

Description

@jim-obrien-orig

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions