📌chore: Add loginUserState
This commit is contained in:
parent
0a1076fdfc
commit
2a0ae14b3d
@ -1,6 +1,8 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { createContext, useState } from 'react'
|
import { loginUserStore } from '@/store/commonAtom'
|
||||||
|
import { createContext, useEffect, useState } from 'react'
|
||||||
|
import { useRecoilState } from 'recoil'
|
||||||
|
|
||||||
export const SessionContext = createContext({
|
export const SessionContext = createContext({
|
||||||
session: {},
|
session: {},
|
||||||
@ -8,5 +10,11 @@ export const SessionContext = createContext({
|
|||||||
|
|
||||||
export default function SessionProvider({ useSession, children }) {
|
export default function SessionProvider({ useSession, children }) {
|
||||||
const [session, setSession] = useState(useSession)
|
const [session, setSession] = useState(useSession)
|
||||||
|
const [loginUserState, setLoginUserState] = useRecoilState(loginUserStore)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoginUserState(session)
|
||||||
|
}, [session])
|
||||||
|
|
||||||
return <SessionContext.Provider value={{ session }}>{children}</SessionContext.Provider>
|
return <SessionContext.Provider value={{ session }}>{children}</SessionContext.Provider>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,3 +32,8 @@ export const slopeSelector = selectorFamily({
|
|||||||
return defaultSlope[degree]
|
return defaultSlope[degree]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const loginUserStore = atom({
|
||||||
|
key: 'loginUserState',
|
||||||
|
default: {},
|
||||||
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user