버튼 태그를 통해 작성한 일자와 기본 데이터를 보여주기까지 구현을 완료했고, 이번 작업에서는 antd Modal Component를 통해 모달을 통해 다이어리의 데이터를 끌어올 수 있게 구현해봤다.
부모 컴포넌트
const showModal = (e) => {
setVisible(true);
setModalText(JSON.stringify(sortList[e.target.parentNode.getAttribute('index')]));
};
태그가 복제되는 컴포넌트
const MapButton = memo(({modalText, index, props, confirmLoading, showModal, handleOk, handleCancel, visible}) => {
return (
<div index={index}>
<Button index={index} onClick={showModal}>
{props.diary_reg_date.slice(0, 10)}일에 작성! {props.diary_weather_type} {props.diary_feel_type}
</Button>
<Modal
mask={true}
maskStyle={{backgroundColor: 'transparent'}}
title='Title'
visible={visible}
onOk={handleOk}
confirmLoading={confirmLoading}
onCancel={handleCancel}>
<p>{modalText}</p>
</Modal>
</div>
);
});