Skip to content

Instantly share code, notes, and snippets.

@mutewinter
Created Feb 4, 2016
Embed
What would you like to do?
MessageList
@listenToFirebase((props) => ({
callback: (dataSnapshot) => {
let messages = [];
dataSnapshot.forEach((childSnapshot) => {
messages.push(
Message.fromDataSnapshot(childSnapshot, { battleId: props.battleId })
);
});
return messages;
},
propName: 'messages',
loadingJSX: <div className="tc ptxxl">Loading messages…</div>,
missingJSX: <div className="tc ptxxl">No messages yet</div>,
ref: messagesRef().child(props.battleId)
}), {
battleId: PropTypes.string.isRequired
})
export default class MessageList extends Component {
// Will have access to an array of messages, guaranteed.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment