我正在使用 MERN 堆栈构建社交媒体应用程序。但是当我无法删除帖子时。
前端-
import { Card, CardActions, CardContent, CardMedia, Button, Typography } from '@material-ui/core';
import ThumbUpAltIcon from '@material-ui/icons/ThumbUpAlt';
import DeleteIcon from '@material-ui/icons/Delete';
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
import moment from 'moment';
import useStyles from './styles.js';
import {useDispatch} from 'react-redux';
import {deletePost} from '../../../actions/posts';
const Post = ({ post, setCurrentId }) => {
const classes = useStyles();
const dispatch = useDispatch();
return (
<Button size="small" color="primary" onClick={() => dispatch(deletePost(post._id)) }>
<DeleteIcon fontSize="small" />
Delete
</Button>
);
}
export default Post;