Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 포스트수정 오류 수정 #19

Merged
merged 9 commits into from
Aug 21, 2023

Conversation

sonji406
Copy link
Contributor

@sonji406 sonji406 commented Aug 21, 2023

📝 PR 목적

포스트 수정 관련 포스트 생성 컴포넌트 및 이미지 저장 API 오류 수정 작업 #18

2023-08-21.8.01.40.mov

📑 작업 내용

  • page.jsx 디렉토리 설정에 따라 params 불러오는 방식 변경 Bugfix 중간점검 및 오류 해결 #18 (위치)
    • 기존 : app/post/editor/[...editId]/page.jsx
    • 변경 : app/post/editor/[userId]/page.jsx, app/post/editor/[userId]/[postId]/page.jsx
  • editor 컴포넌트 기존 포스트 editor.js로 불러오는 부분 수정 (위치)
    • 이전
      • content가 변경될 때마다 EditorJS가 초기화되어 렌더링이 제대로 되지 않는 오류 발생
    • 수정
      • EditorJS가 이미 있으면 재사용하여 기존 EditorJS에 데이터를 렌더링
      • await ref.current.isReady를 사용하여 EditorJS 렌더링 준비를 기다린 후 데이터 렌더링
  • S3 이미지 업로드 API 수정 (위치)
    • 코드를 정리하다가 잘못 제거하여 오류 발생 (수정이 되면 테스트를 꼼꼼히 하겠습니다.)

🚧 주의 사항

@sonji406 sonji406 added the enhancement New feature or request label Aug 21, 2023
@sonji406 sonji406 self-assigned this Aug 21, 2023
Comment on lines 33 to 31
return () => {
if (ref.current) {
ref.current.destroy();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEffect 마지막에 해제 하는거 지우셨는데 없어도 되는 코드인가요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정할 때 여기에서 에러가 발생했던 걸로 기억하는데, 혹시 어떤 이유였는지 설명해주실 수 있을까요?

Copy link
Contributor Author

@sonji406 sonji406 Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 기존에는 생성되는 EditorJS 인스턴스가 메모리에 계속 남아서 있어서 destroy로 제거해줬는데
바뀐 방법에는 이미 존재하면 새로운 EditorJS 인스턴스를 생성하지 않고 기존 인스턴스를 재사용하여 destroy를 사용하지 않아도 됩니다.

Copy link
Contributor Author

@sonji406 sonji406 Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 56 to 62
let response = {};

if (isModify) {
await axios.put(`/api/v1/posts/${postId}`, postData);
router.push(`/posts/${author}`);
response = await axios.put(`/api/v1/posts/${postId}`, postData);
} else {
response = await axios.post('/api/v1/posts', postData);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삼항 연산자를 쓰면 response를 const로 선언해서 사용할 수 있을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 의견 감사합니다.
반영하였습니다.

Copy link
Contributor

@hamsterster hamsterster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다! 확인했습니다.

Copy link
Contributor

@Josh5519 Josh5519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

버그 잡느라 수고하셨습니다.

@sonji406 sonji406 merged commit 39fa708 into dev Aug 21, 2023
@hamsterster hamsterster added bugfix bug fixed and removed enhancement New feature or request labels Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix bug fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants