refactor: 페이지 이동 후 복귀 시 canvas 표출이 안되는 현상 수정

This commit is contained in:
Daseul Kim 2024-10-15 16:17:41 +09:00
parent 594a1abbb1
commit ab3aa6d993
2 changed files with 15 additions and 14 deletions

View File

@ -29,7 +29,7 @@ export default function CanvasFrame({ plan }) {
useEffect(() => { useEffect(() => {
loadCanvas() loadCanvas()
}, [plan]) }, [plan, canvas])
useEffect(() => { useEffect(() => {
switch (currentMenu) { switch (currentMenu) {

View File

@ -25,8 +25,7 @@ export default function CanvasLayout() {
const handleCurrentPlan = (newCurrentId) => { const handleCurrentPlan = (newCurrentId) => {
// console.log('currentPlan newCurrentId: ', newCurrentId) // console.log('currentPlan newCurrentId: ', newCurrentId)
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
if (!currentCanvasPlan?.id || currentCanvasPlan.id !== newCurrentId) {
if (currentCanvasPlan?.id && checkModifiedCanvasPlan()) { if (currentCanvasPlan?.id && checkModifiedCanvasPlan()) {
swalFire({ swalFire({
html: getMessage('common.message.confirm.save') + `</br>${currentCanvasPlan.name}`, html: getMessage('common.message.confirm.save') + `</br>${currentCanvasPlan.name}`,
@ -92,17 +91,19 @@ export default function CanvasLayout() {
} }
useEffect(() => { useEffect(() => {
getCanvasByObjectNo(sessionState.userId, objectNo).then((res) => { if (!currentCanvasPlan) {
console.log('canvas 목록 ', res) getCanvasByObjectNo(sessionState.userId, objectNo).then((res) => {
if (res.length > 0) { // console.log('canvas ', res)
setInitCanvasPlans(res) if (res.length > 0) {
setPlans(res) setInitCanvasPlans(res)
handleCurrentPlan(res.at(-1).id) // last setPlans(res)
setPlanNum(res.length) handleCurrentPlan(res.at(-1).id) // last
} else { setPlanNum(res.length)
addNewPlan() } else {
} addNewPlan()
}) }
})
}
}, []) }, [])
return ( return (