-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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