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,8 +91,9 @@ export default function CanvasLayout() {
} }
useEffect(() => { useEffect(() => {
if (!currentCanvasPlan) {
getCanvasByObjectNo(sessionState.userId, objectNo).then((res) => { getCanvasByObjectNo(sessionState.userId, objectNo).then((res) => {
console.log('canvas 목록 ', res) // console.log('canvas ', res)
if (res.length > 0) { if (res.length > 0) {
setInitCanvasPlans(res) setInitCanvasPlans(res)
setPlans(res) setPlans(res)
@ -103,6 +103,7 @@ export default function CanvasLayout() {
addNewPlan() addNewPlan()
} }
}) })
}
}, []) }, [])
return ( return (