Download react-redux-realworld-example-app/src/components/Article/DeleteButton.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-redux-realworld-example-app/src/components/Article/DeleteButton.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-redux-realworld-example-app/src/components/Article/DeleteButton.js
-
curl -L -o DeleteButton.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-redux-realworld-example-app/src/components/Article/DeleteButton.js
718 Bytes
| import React from 'react'; | |
| import agent from '../../agent'; | |
| import { connect } from 'react-redux'; | |
| import { DELETE_COMMENT } from '../../constants/actionTypes'; | |
| const mapDispatchToProps = dispatch => ({ | |
| onClick: (payload, commentId) => | |
| dispatch({ type: DELETE_COMMENT, payload, commentId }) | |
| }); | |
| const DeleteButton = props => { | |
| const del = () => { | |
| const payload = agent.Comments.delete(props.slug, props.commentId); | |
| props.onClick(payload, props.commentId); | |
| }; | |
| if (props.show) { | |
| return ( | |
| <span className="mod-options"> | |
| <i className="ion-trash-a" onClick={del}></i> | |
| </span> | |
| ); | |
| } | |
| return null; | |
| }; | |
| export default connect(() => ({}), mapDispatchToProps)(DeleteButton); | |