11var React = require ( 'react' ) ;
22var Reflux = require ( 'reflux' ) ;
33var ImageStore = require ( '../stores/image-store' ) ;
4+ var CommentStore = require ( '../stores/comment-store' ) ;
45var Actions = require ( '../actions' ) ;
6+ var CommentBox = require ( './comment-box' ) ;
57
68module . exports = React . createClass ( {
79 mixins : [
8- Reflux . listenTo ( ImageStore , 'onChange' )
10+ Reflux . listenTo ( ImageStore , 'onChange' ) ,
11+ Reflux . listenTo ( CommentStore , 'onChange' )
912 ] ,
1013 getInitialState : function ( ) {
1114 return {
12- image : null
15+ image : null ,
16+ comment : null
1317 }
1418 } ,
1519 componentWillMount : function ( ) {
@@ -33,8 +37,17 @@ module.exports = React.createClass({
3337 < h5 > { this . state . image . description } </ h5 >
3438 </ div >
3539 </ div >
40+ < h3 > Comments</ h3 >
41+ { this . renderComments ( ) }
3642 </ div >
3743 } ,
44+ renderComments : function ( ) {
45+ if ( ! this . state . comments ) {
46+ return null
47+ }
48+
49+ return < CommentBox comments = { this . state . comments } />
50+ } ,
3851 renderImage : function ( ) {
3952 if ( this . state . image . animated ) {
4053 return < video preload = "auto" autoPlay = "autoplay" loop = "loop" webkit-playsinline >
@@ -46,7 +59,8 @@ module.exports = React.createClass({
4659 } ,
4760 onChange : function ( ) {
4861 this . setState ( {
49- image : ImageStore . find ( this . props . params . id )
62+ image : ImageStore . find ( this . props . params . id ) ,
63+ comments : CommentStore . comment
5064 } ) ;
5165 }
5266} ) ;
0 commit comments