File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change 1
- import { useState , useEffect , ReactElement } from "react" ;
1
+ import { useState , useEffect , ReactElement , useCallback } from "react" ;
2
2
import { useTranslation } from "next-i18next" ;
3
3
import Loader from "@/components/ui/Loader" ;
4
4
import ArrowButton from "@/components/ui/button/Arrow" ;
@@ -26,23 +26,24 @@ export default function EmailVerification(): ReactElement {
26
26
const { locale } = useRouter ( ) ;
27
27
const dispatch = useDispatch ( ) ;
28
28
29
+ const verify = useCallback ( async ( ) => {
30
+ const code = router . query . code as string ;
31
+ if ( ! code ) {
32
+ router . push ( "/404" ) ;
33
+ return ;
34
+ }
35
+ try {
36
+ await dispatch ( verifyEmail ( { locale : locale as string , payload : { code } } ) ) ;
37
+ await auth . currentUser ?. reload ( ) ;
38
+ setVerified ( true ) ;
39
+ } catch ( error ) {
40
+ console . error ( error ) ;
41
+ }
42
+ } , [ ] ) ;
43
+
29
44
useEffect ( ( ) => {
30
- const verify = async ( ) => {
31
- const code = router . query . code as string ;
32
- if ( ! code ) {
33
- router . push ( "/404" ) ;
34
- return ;
35
- }
36
- try {
37
- await dispatch ( verifyEmail ( { locale : locale as string , payload : { code } } ) ) ;
38
- await auth . currentUser ?. reload ( ) ;
39
- setVerified ( true ) ;
40
- } catch ( error ) {
41
- console . error ( error ) ;
42
- }
43
- } ;
44
45
verify ( ) ;
45
- } , [ dispatch , locale , router . query . code ] ) ;
46
+ } , [ verify ] ) ;
46
47
47
48
const goHome = ( ) => {
48
49
router . push ( "/login" ) ;
You can’t perform that action at this time.
0 commit comments