Skip to content

Instantly share code, notes, and snippets.

@khanghoang
Created January 16, 2016 09:48
Show Gist options
  • Save khanghoang/6ced592812b4e4f096cb to your computer and use it in GitHub Desktop.
Save khanghoang/6ced592812b4e4f096cb to your computer and use it in GitHub Desktop.
class ListCommentsContainer extends Component {
constructor(props) {
super(props);
this.state = {
comments: [],
isLoading: true
}
}
componentDidMount() {
// in the real world, this will be async call to
// some APIs and get response.
setTimeout(() => {
this.setState(Object.assign({}, {
comments: [
"this is first comment",
"this is second comment",
"this is third comment",
"this is fourth comment",
"this is fifth comment",
]
}, {isLoading: false}));
}, 1000);
}
render() {
return (
this.state.isLoading ?
<div>Loading...</div> :
<ListCommentsComponent
comments={this.state.comments}
/>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment