这是我的 singlePost 组件的代码
import { useLocation } from "react-router-dom";
import "./singlePost.css";
export default function SinglePost() {
//[count,setCount] = useState(""); works here
const location = useLocation();
console.log(location);
return (
<div className="singlePost">
<div className="singlePostWrapper">
<img src="https://images.unsplash.com/photo-1591117207239-788bf8de6c3b?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Ym94aW5nfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&w=1000&q=80" alt="" className="singlePostImg" />
</div>
<h1 className="singlePostTitle">
Lorem bruh momentum
<div className="singlePostEdit">
<i className="singlePostIcon far fa-edit"></i>
<i className="singlePostIcon far fa-trash-alt"></i>
</div>
</h1>
<div className="singlePostInfo">
<span className="singlePostAuthor">Author : <b>Anmol Nukal</b></span>
<span className="singlePostDate">1 hr ago</span>
</div>
<p className="singlePostDesc">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Id velit sit quasi, quod iste unde doloribus asperiores expedita quisquam obcaecati vitae earum laborum nostrum eius iure laboriosam omnis commodi aperiam?
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Omnis distinctio ullam dolorem commodi quae dolore sunt, atque eaque eum repellat hic quam sint provident dicta quis optio asperiores odio quos.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam eius modi alias temporibus laborum obcaecati at corrupti eos, facere sapiente nobis asperiores quidem saepe debitis voluptatibus tenetur fuga delectus nostrum.
</p>
</div>
)
}
我不知道为什么 useLocation() 不起作用 如果我用 useState() 之类的其他钩子替换 useLocation() ,它工作正常