Skip to content

Instantly share code, notes, and snippets.

@mutewinter
Created February 4, 2016 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutewinter/2fdd117320b4569e71f9 to your computer and use it in GitHub Desktop.
Save mutewinter/2fdd117320b4569e71f9 to your computer and use it in GitHub Desktop.
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