https://sso-feeling.tistory.com/556
useNavigate다바꿈
주소창에서 파람따기
const { pathname } = useLocation();
const post_id = pathname.split("/")[3];
이동하기 이제 링크안쓰고 함수형으로 해서 onClick
const goToEdit = () => {
navigate(`/dimo/create/edits/${post_id}`, {
state: {
isedit: true,
post_id: post_id,
board: "QNA",
},
});
};
<button onClick={goToEdit}>수정</button>
이렇게 해주면 링크의 기능을 다쓸수있음
https://velog.io/@sham/react-router-dom-v6로-페이지-이동하기
https://velog.io/@soryeongk/ReactRouterDomV6
history를 네비게이터로 바꾸기
history.replace("/dimo/qna");
navigate("/dimo/qna", { replace: true });
navigate(-1) 이러면 goback
navigate(-2) 이러면 2칸 뒤로가기
navigate(`/dimo/create/`, {
state: {
isedit: true,
post_id: post_id,
board: "QNA",
},
});
let location = useLocation();
let navigate = useNavigate();
console.log(location);
console.log(location.pathname);
console.log(location.state);