handleActions({ 'add comment'(state, action) { const id = action.payload.videoId; const videoComment = state.filter((comment) => comment.videoId === id); return [{ videoId: action.payload.videoId, text: action.payload.text, author: action.payload.author, id: (videoComment) ? videoComment.length+1 : 0, }, ...state]; }, }, comments)
render() { const { isLoaded, post } = this.state; if (!isLoaded) { return <div>Loading...</div>; } return ( <div className="blog-post"> <h2 className="blog-post-title">{post.title}</h2> <p className="blog-post-meta">{new Date(post.date).toUTCString()} by <a href="/about/">{post.author}</a></p> <p><img width="480" src={post.image} alt="" /></p> <p>{post.summary}</p> <p>{post.fullText}</p> </div> ); }