Created
March 9, 2016 04:35
-
-
Save Vivekbhusal/a62bc0dc88daf4c1008c 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 MyPosts extends Component{ | |
constructor(props) { | |
super(props); | |
this.handleDeletePost = this.handleDeletePost.bind(this); | |
} | |
handleDeletePost(postID) { | |
const {dispatch} = this.props; | |
dispatch(deletePostsRequest(postID)) | |
} | |
render() { | |
return ( | |
<div> | |
<div className="post-sidebar-title" dangerouslySetInnerHTML= {{__html: title}}></div> | |
<span className="post-actions"> | |
{attachDetachAction} | |
<span | |
onClick={this.handleDeleteClipping.bind(this, id)} | |
className="remove-post"><i className="glyphicon glyphicon-remove"></i></span> | |
</span> | |
<div className="post-sidebar-source">{source}</div> | |
<div className="post-sidebar-content" dangerouslySetInnerHTML= {{__html: content}}></div> | |
</div> | |
</div> | |
) | |
} | |
} | |
##reducer.js | |
export function deletePostsRequest(postID) { | |
let API = API_DELETE_POST; | |
return dispatch => { | |
dispatch(deletePosts(postID)); | |
return fetch(API.url(postID), { | |
method: API.type, | |
credentials: 'same-origin' | |
}).then(function(response) { | |
if(!response.ok) { | |
//revert back | |
} | |
}); | |
} | |
} | |
function deletePosts(postID) { | |
return { | |
type: DELETE_POST, | |
postID | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment