Refactor 1. custom hook 추가 (scheduleAdd component) 2. 모달 열기방식 수정(테스트로 kebob modal만 작업) #218
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.
scheduleAdd 컴포넌트에 카드색상 선택시 border색상을 주는 부분이 상태가 굉장히 많고 하드코딩된 부분이 있었습니다. 불필요하게 중복되는 코드를 줄이기 위해 custom hook으로 만들었습니다. (useCardColorSelector.jsx)
ScheduleDetail컴포넌트 변경사항 보시면
{modalOpen&&...}
KebobModal을 여는 상태값을 scheduleDetail에서 논리연산자로 Kebob을 열지 말지 결정하고있었는데
scheduelDeail이 아닌, KebobModal컴포넌트 내에서 modalOpen여부에 따라 열지 말지 결정하는 방식으로 바꿨습니다.
기존의 코드대로 모달을 컨트롤하는게 일반적인 방식이지만 이렇게 수정한 이유는 상위컴포넌트에선 항상 컴포넌트를 열어두고, KebobModal.jsx내에서 보여줄지의 여부를 결정함으로써 모달 내의 상태를 초기값으로 reset할 수 있기 때문입니다.
현재 Kebob모달에서는 input이나 다른 특별한 state가 없긴하지만 참여자선택 followList모달과 같이 모달 내에 state가 존재하고있어서 열고 닫을 때마다 상태를 초기화해야할 땐 이런 방식으로 하면 좋다고 합니다! 오늘은 공부하면서 kebob에만 적용했고 차차 다른 모달에도 적용해볼게요
#217