Created
January 16, 2016 09:48
-
-
Save khanghoang/6ced592812b4e4f096cb to your computer and use it in GitHub Desktop.
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
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