Skip to content

Instantly share code, notes, and snippets.

@WDever
Created May 5, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WDever/3af3d245cffa6e0e775aeb360aca840a to your computer and use it in GitHub Desktop.
Save WDever/3af3d245cffa6e0e775aeb360aca840a to your computer and use it in GitHub Desktop.
type GetCodeStatus = | 'none'
| 'PARTIALLY_AUTHENTICATED'
| 'NOT_AUTHENTICATED'
| 'BAD_PARAMS';
const getCodeStatus = useRef<GetCodeStatus>('none');
const setGetCodeStatus = (resStatus: GetCodeStatus) => {
getCodeStatus.current = resStatus;
};
const asyncSetGetCodeStatus = async (resStatus: GetCodeStatus) => {
setGetCodeStatus(resStatus);
console.log(getCodeStatus);
};
// useRef로 만든 로컬 변수
const verifyPhoneNum = async () => {
if (getCodeStatus === 'PARTIALLY_AUTHENTICATED') {
console.log(state);
console.log(code);
console.log(signKey);
verifyPhone({ code, state, signKey });
} else {
console.log(state);
console.log(getCodeStatus);
console.log(signKey);
alert('핸드폰 인증 실패');
}
};
const handleResponse = async (res: PhoneCheckResType) => {
await asyncSetCode(res.code);
await asyncSetGetCodeStatus(res.status);
await verifyPhoneNum();
console.log(res);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment