Created
May 5, 2019 14:25
-
-
Save WDever/3af3d245cffa6e0e775aeb360aca840a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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