Skip to content

Instantly share code, notes, and snippets.

@hckhanh
Last active February 9, 2019 14:09
Show Gist options
  • Save hckhanh/c33cdc507cc26932fb98477624ba5591 to your computer and use it in GitHub Desktop.
Save hckhanh/c33cdc507cc26932fb98477624ba5591 to your computer and use it in GitHub Desktop.
higher-order component injected
import React, { Component } from "react";
import DataSource from "../DataSource";
import withSubscription from "./withSubscription";
const Comment = ({ comment }) => <>{comment}</>;
class CommentList extends Component {
render() {
return (
<>
{this.props.data.map(comment => (
<Comment comment={comment} key={comment.id} />
))}
</>
);
}
}
export default withSubscription(CommentList, DataSource =>
DataSource.getComments()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment