import React from "react";
import Detailpost from "../../DetailPost/detailpost";
const Post = (props) => {
return (
<div className="post">
<div className="img-thum">
<img src="https://placeimg.com/200/150/tech" alt="IMG" />
</div>
<div className="content">
<div
className="title"
onClick={()=>props.Detail(props.data.id)}
>
{props.data.title}
</div>
<div className="Body">{props.data.body}</div>
<div className="rem">
<button
className="remove"
onClick={() => props.remove(props.data.id)}
>
Remove
</button>
<button
className="update"
onClick={() => props.update(props.data)}
>
Update
</button>
</div>
</div>
);
}
export default Post;
In this case I'll make when I click the title I move to another page.
handleDetail = (id) => {
const navigate = useNavigate();
navigate('/detail-post', { UserId: id })
}
but when I run the code I get some problem:
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
anyone can help me..