📌chore: setCorrentObjectNo 위치 변경
This commit is contained in:
parent
87fba29717
commit
dd45849c75
@ -1,6 +1,9 @@
|
||||
'use client'
|
||||
|
||||
import { correntObjectNoState } from '@/store/settingAtom'
|
||||
import { usePathname, useSearchParams } from 'next/navigation'
|
||||
import { createContext, useEffect, useState } from 'react'
|
||||
import { useSetRecoilState } from 'recoil'
|
||||
import { useLocalStorage } from 'usehooks-ts'
|
||||
|
||||
// export const GlobalDataContext = createContext({
|
||||
@ -15,6 +18,20 @@ const GlobalDataProvider = ({ children }) => {
|
||||
// TODO: 임시 조치이며 개발 완료시 삭제 예정 -> 잊지말기...
|
||||
const [managementStateLoaded, setManagementStateLoaded] = useLocalStorage('managementStateLoaded', null)
|
||||
|
||||
const pathname = usePathname()
|
||||
const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||
const searchParams = useSearchParams()
|
||||
const objectNo = searchParams.get('objectNo')
|
||||
const pid = searchParams.get('pid')
|
||||
useEffect(() => {
|
||||
if (pathname === '/floor-plan') {
|
||||
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
||||
notFound()
|
||||
}
|
||||
setCorrentObjectNo(objectNo)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (managementState !== null) {
|
||||
setManagementStateLoaded(managementState)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
'ues client'
|
||||
|
||||
import { correntObjectNoState } from '@/store/settingAtom'
|
||||
// import { correntObjectNoState } from '@/store/settingAtom'
|
||||
import { notFound, usePathname, useSearchParams } from 'next/navigation'
|
||||
import { createContext, useReducer, useState, useEffect } from 'react'
|
||||
import { useSetRecoilState } from 'recoil'
|
||||
// import { useSetRecoilState } from 'recoil'
|
||||
|
||||
const reducer = (prevState, nextState) => {
|
||||
return { ...prevState, ...nextState }
|
||||
@ -42,20 +42,20 @@ export const FloorPlanContext = createContext({
|
||||
})
|
||||
|
||||
const FloorPlanProvider = ({ children }) => {
|
||||
const pathname = usePathname()
|
||||
const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||
// const pathname = usePathname()
|
||||
// const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||
const searchParams = useSearchParams()
|
||||
const objectNo = searchParams.get('objectNo')
|
||||
const pid = searchParams.get('pid')
|
||||
useEffect(() => {
|
||||
console.log('🚀 ~ useEffect ~ objectNo:')
|
||||
if (pathname === '/floor-plan') {
|
||||
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
||||
notFound()
|
||||
}
|
||||
setCorrentObjectNo(objectNo)
|
||||
}
|
||||
}, [])
|
||||
// useEffect(() => {
|
||||
// console.log('🚀 ~ useEffect ~ objectNo:')
|
||||
// if (pathname === '/floor-plan') {
|
||||
// if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
||||
// notFound()
|
||||
// }
|
||||
// setCorrentObjectNo(objectNo)
|
||||
// }
|
||||
// }, [])
|
||||
|
||||
//useEffect(() => { // 오류 발생으로 useEffect 사용
|
||||
// if (pathname === '/floor-plan') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user