@@ -4,7 +4,7 @@ import { useSignUp } from '@clerk/expo';
44import { useRouter } from 'expo-router' ;
55
66export default function SignUpScreen ( ) {
7- const { isLoaded , signUp, setActive } = useSignUp ( ) ;
7+ const { signUp } = useSignUp ( ) ;
88 const router = useRouter ( ) ;
99
1010 const [ emailAddress , setEmailAddress ] = React . useState ( '' ) ;
@@ -13,46 +13,19 @@ export default function SignUpScreen() {
1313 const [ code , setCode ] = React . useState ( '' ) ;
1414
1515 const onSignUpPress = async ( ) => {
16- if ( ! isLoaded ) {
17- return ;
18- }
19-
20- try {
21- await signUp . create ( {
22- emailAddress,
23- password,
24- } ) ;
25-
26- await signUp . prepareEmailAddressVerification ( { strategy : 'email_code' } ) ;
27-
28- setPendingVerification ( true ) ;
29- } catch ( err : any ) {
30- // See https://clerk.com/docs/custom-flows/error-handling
31- // for more info on error handling
32- console . error ( JSON . stringify ( err , null , 2 ) ) ;
33- }
16+ await signUp . password ( { emailAddress, password } ) ;
17+ await signUp . verifications . sendEmailCode ( { emailAddress } ) ;
18+ setPendingVerification ( true ) ;
3419 } ;
3520
3621 const onPressVerify = async ( ) => {
37- if ( ! isLoaded ) {
38- return ;
39- }
40-
41- try {
42- const completeSignUp = await signUp . attemptEmailAddressVerification ( {
43- code,
22+ await signUp . verifications . verifyEmailCode ( { code } ) ;
23+ if ( signUp . status === 'complete' ) {
24+ await signUp . finalize ( {
25+ navigate : async ( ) => {
26+ router . replace ( '/' ) ;
27+ } ,
4428 } ) ;
45-
46- if ( completeSignUp . status === 'complete' ) {
47- await setActive ( { session : completeSignUp . createdSessionId } ) ;
48- router . replace ( '/' ) ;
49- } else {
50- console . error ( JSON . stringify ( completeSignUp , null , 2 ) ) ;
51- }
52- } catch ( err : any ) {
53- // See https://clerk.com/docs/custom-flows/error-handling
54- // for more info on error handling
55- console . error ( JSON . stringify ( err , null , 2 ) ) ;
5629 }
5730 } ;
5831
0 commit comments