카테고리 없음
페이지 최초 렌더링시 useEffect로 해당 게시글 id값 위치로 scroll시키기(자동스크롤)
maggieH
2022. 12. 20. 19:07
const targetId = document.getElementById(`usage${customerCenterId}`)
useEffect(()=>{
if(!(customerCenterId === null || customerCenterId === undefined)){
targetId?.scrollIntoView({behavior:'smooth',top:targetId.offsetTop})
}
},[customerCenterId])
return (
<>
<p className='p-6 text-center text-caption1_600 text-gray_160 bg-gray_15 border-b'>힐리어리 앱에 대해 궁금하신 점을 문의해주세요.</p>
<ul className='bg-white' ref={scrollRef}>
{customerCenter?.map((el,idx)=>(
<li className='p-6 border-b' key={idx}
id={`usage${el?.id}`}
onClick={()=>{dispatch(onSetCustomerCenterQList(el?.id));navigate("/contact/usageqa")}}
>
{InquiryList(el)}
</li>
))}
</ul>
</>
)