Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ghostffcode/adefda428cc0167b3c9567e292595367 to your computer and use it in GitHub Desktop.
Save ghostffcode/adefda428cc0167b3c9567e292595367 to your computer and use it in GitHub Desktop.
How to mixin reactfire to es6 react class. More info: https://github.com/firebase/reactfire/issues/38#issuecomment-192963227
import React, { Component } from 'react'
import Firebase from 'firebase'
import ReactFireMixin from 'reactfire'
import reactMixin from 'react-mixin'
const ref = new Firebase('https://<APPNAME>.firebaseio.com/users')
class UsersList extends Component {
constructor (props, context) {
super(props, context)
this.state = {
users: []
}
}
componentDidMount () {
this.bindAsArray(ref, 'users')
}
renderUser (user) {
return <p>{user.name}</p>
}
render () {
return (
<div>
{this.state.languages.map(this.renderLanguage)}
</div>
)
}
}
reactMixin(UsersList.prototype, ReactFireMixin)
export default UsersList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment