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