Skip to content

Commit

Permalink
remove: recoil initial
Browse files Browse the repository at this point in the history
  • Loading branch information
uiop5809 committed Sep 2, 2024
1 parent 87b6440 commit 5755ba2
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/recoil/Recoil.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
'use client'

import { ReactNode } from 'react'
import { RecoilRoot, MutableSnapshot } from 'recoil'
import { userInfoState } from '@/recoil/UserInfo'
import { RecoilRoot } from 'recoil'

interface RecoilRootProps {
children: ReactNode
initialUserInfo?: any
}

const initializeState = (snapshot: MutableSnapshot, initialUserInfo?: any) => {
if (initialUserInfo) {
snapshot.set(userInfoState, initialUserInfo)
}
}

const Recoil = ({ children, initialUserInfo }: RecoilRootProps) => {
return (
<RecoilRoot
initializeState={(snapshot) => initializeState(snapshot, initialUserInfo)}
>
{children}
</RecoilRoot>
)
}

Recoil.defaultProps = {
initialUserInfo: null,
const Recoil = ({ children }: RecoilRootProps) => {
return <RecoilRoot>{children}</RecoilRoot>
}

export default Recoil

0 comments on commit 5755ba2

Please sign in to comment.