Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ 해당 이슈 번호 ✨
closes #468
todo
📌 내가 알게 된 부분
기존에는 글 수정 시 글 데이터를 글 상세페이지에서 location.state로 받아왔었습니다.
그러다보니 location.state 가 새로고침이나 뒤로가기 등으로 접근하면 Null 값으로 받아와지는 이슈가 발생하여서, 기존에 localStorage등을 활용하면서 location.state를 잡아두는 방식으로 이슈 해결시도했습니다.
하지만 뒤로가기를 하면 location.state를 받아올 수가 없어서 . . 기존에 있던 글 수정시 글조회 api를 사용하였습니다.
글 수정시 글 조회 api는 해당 글 ID를 request로 전달하여야 하는데, 이걸 받아올 수 있는 방법이 글 상세페이지에서의 Location.state밖에 없더라구요.
그래서 기존 postPage (글 작성 페이지) 라우터에 옵셔널 쿼리를 추가해서 글 상세페이지에서 글 수정하기페이지에 접근할 경우, 라우터에 postId 를 쿼리로 추가할 수 있도록 해두었습니다.
새로고침, 뒤로가기 등의 이슈가 모두 해결되었어요
글 상세페이지에서 수정하기로 넘어올 경우
옵셔널 쿼리여서 해당 부분은 수정없습니다. 기존대로 navigate해주면 돼요
📌 질문할 부분
📌스크린샷(선택)
2024-11-05.7.01.15.mov