-
Notifications
You must be signed in to change notification settings - Fork 2
fix:모달 버그 해결, feat:모달 테스트 페이지 추가 #36
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
base: develop
Are you sure you want to change the base?
Conversation
const isModalOpen = storeModalOpen((state) => state.modalState.isModalOpen) | ||
const setModalOpen = storeModalOpen((state) => state.setModalState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setModalOpen -> setIsModalOpen 으로 다시 변경하는게 좋을 것 같아요-
아까는 생각을 못했는데 isModalOpen을 변경해주는거라 setIsModalOpen이 더 직관적인 것 같습니다-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { create } from 'zustand'
type ModalState = {
isModalOpen: boolean
prevPath: string
title: string
subTitle?: string
}
interface storeModalState {
modalState: ModalState
setModalState: (state: Partial<ModalState>) => void
clearModal: () => void
}
const initState: ModalState = {
isModalOpen: false,
prevPath: '',
title: '',
subTitle: '',
}
export const storeModalOpen = create<storeModalState>((set) => ({
modalState: initState,
setModalState: (newState) =>
set((cur) => ({ modalState: { ...cur.modalState, ...newState } })),
clearModal: () => set(() => ({ modalState: initState })),
}))
현재 isModalOpen뿐만 아니라 prevPath, title, subTitle 모두 스토어에서 관리하도록 조치하면서 이름을 변경했습니다.
const setModalState = storeModalOpen((state) => state.setModalState)
해당 라인에서 setModalOpen 의 변수명 또한 setModalState 로 변경 완료했습니다
src/components/modal/ModalHeader.tsx
Outdated
<button onClick={(e) => handleClickCancel(e)}> | ||
<X size={18} /> | ||
<X size={18} onClick={() => onClose()} className="cursor-pointer" /> | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아이콘에 onClose가 있으면 버튼의 onClick에는 e.preventDefault()만 있어도 되지 않을까요-?!
2개가 중복되는 것 같아요-
2개가 다 필요 한걸까요-?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { useModal } from '@/hooks/useModal'
import { X } from 'lucide-react'
type ModalHeaderProps = {
title: string
subTitle?: string | null
}
const ModalHeader = ({ title, subTitle = null }: ModalHeaderProps) => {
const { closeModal } = useModal()
const handleClickCancel = (e: React.MouseEvent) => {
e.preventDefault()
closeModal()
}
return (
<header className="flex w-full justify-between border-b border-gray-300 p-6 text-gray-900">
<div className="flex flex-col">
<h1 className="text-lg font-semibold">{title}</h1>
<h2 className="text-sm font-normal text-gray-500">{subTitle}</h2>
</div>
<button onClick={(e) => handleClickCancel(e)} className="cursor-pointer">
<X size={18} />
</button>
</header>
)
}
export default ModalHeader
수정 완료했습니다
src/hooks/useModal.ts
Outdated
const openModal = (modalPath: string, title: string, subTitle?: string) => { | ||
const currentPath = location.pathname | ||
navigate(modalPath) | ||
storeModalOpen.getState().setIsModalState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property 'setIsModalState' does not exist on type 'storeModalState'. Did you mean 'setModalState'?
build 오류 났어요- 수정해주세요-
src/hooks/useModal.ts
Outdated
subTitle?: string | ||
) => { | ||
navigate(modalPath) | ||
storeModalOpen.getState().setIsModalState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property 'setIsModalState' does not exist on type 'storeModalState'. Did you mean 'setModalState'?
여기도 build 오류 났습니다- 수정해주세요-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useModal.ts에서 변경 이후 저장을 안해서 생겼던 문제였습니다. 수정후 빌드 확인 했습니다
change repuest가 풀리퀘를 다시 작성하라는 건지 몰랐어요ㅜㅜ
그냥 수정하라는건줄 알았는데 아니었네요....ㅜㅜ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인 했습니다-
💡 개요
📝 상세 내용
✅ 체크리스트
🔗 관련 이슈