-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/kakao login #134
base: main
Are you sure you want to change the base?
Feat/kakao login #134
Conversation
- 리팩터링 필요
- 훅 분리
- ProtectedRoute 추가 - useAccessToken 추가 - useLocalStorage 추가
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
export const ProtectedRoute: FC<ProtectedRouteProps> = ({ | ||
isAllowed, | ||
redirectTo, | ||
children, | ||
}) => { | ||
if (!isAllowed) { | ||
return <Navigate replace to={redirectTo} /> | ||
} | ||
|
||
return children | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const ProtectedRoute: FC<ProtectedRouteProps> = ({ | |
isAllowed, | |
redirectTo, | |
children, | |
}) => { | |
if (!isAllowed) { | |
return <Navigate replace to={redirectTo} /> | |
} | |
return children | |
} | |
export const ProtectedRoute: FC<ProtectedRouteProps> = ({ | |
isAllowed, | |
redirectTo, | |
element, | |
path | |
}) => { | |
return ( | |
<Route | |
path={path} | |
element={isAllowed ? element : <Navigate replace to={redirectTo} />} | |
/> | |
} |
이런 구현은 어떨까요??
사용하는 곳에서 아래처럼 쓸 수 있을 것 같아요!
<Routes>
<Route path="/" element={<MapAppContainer />} />
<Route path="/login" element={<Login />} />
<ProtectedRoute
path="/protectePath"
isAllowed={isAvailable}
redirectTo="/login"
element={
<div>Protected Page</div>
}
/>
</Routes>
const { | ||
data: { | ||
signIn: {accessToken, expiredAt}, | ||
}, | ||
} = await urqlClient | ||
.mutation(SignInDocumnet, { | ||
input: { | ||
code: access_token, | ||
type: 'KAKAO', | ||
}, | ||
}) | ||
.toPromise() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMutation
훅 사용하지 않고 이렇게 처리하신 이유가 있을까요??? 👀👀👀
- 함수표현식으로 변경
Description
Help Wanted 👀
Related Issues
Checklist ✋
{PR type}: {PR title}
로 맞췄습니다. (type 예시: feat | fix | BREAKING CHANGE | chore | ci | docs | style | refactor | perf | test) (참고: conventional commits)yarn build
,yarn test
)