@@ -7,22 +7,19 @@ This introducing changes to `useReverification`, the changes include removing th
77
88``` tsx {{ filename: 'src/components/MyButton.tsx' }}
99import { useReverification } from ' @clerk/clerk-react'
10- import { isClerkRuntimeError } from ' @clerk/clerk-react/error'
10+ import { isReverificationCancelledError } from ' @clerk/clerk-react/error'
1111
1212export function MyButton() {
1313 const enhancedFetcher = useReverification (() => fetch (' /api/balance' ))
1414
1515 const handleClick = async () => {
1616 try {
1717 const myData = await enhancedFetcher ()
18- // If `myData` is null, the user canceled the reverification process
19- // You can choose how your app responds. This example returns null.
20- if (! myData ) return
2118 } catch (e ) {
22- // Handle error returned from the fetcher
19+ // Handle error returned from the fetcher here
2320
2421 // You can also handle cancellation with the following
25- if (isClerkRuntimeError (err ) && err . code === ' reverification_cancelled ' ) {
22+ if (isReverificationCancelledError (err )) {
2623 // Handle the cancellation error here
2724 }
2825 }
@@ -37,8 +34,8 @@ to handle re-verification flow. When the handler is passed the default UI our AI
3734
3835
3936``` tsx {{ filename: 'src/components/MyButtonCustom.tsx' }}
40- import { useReverification } from ' @clerk/react'
41- import { isClerkRuntimeError } from ' @clerk/react/error'
37+ import { useReverification } from ' @clerk/clerk- react'
38+ import { isReverificationCancelledError } from ' @clerk/clerk- react/error'
4239
4340export function MyButton() {
4441 const enhancedFetcher = useReverification (() => fetch (' /api/balance' ), {
@@ -50,11 +47,13 @@ export function MyButton() {
5047 const handleClick = async () => {
5148 try {
5249 const myData = await enhancedFetcher ()
53- // If `myData` is null, the user canceled the reverification process
54- // You can choose how your app responds. This example returns null.
55- if (! myData ) return
5650 } catch (e ) {
57- // Handle error returned from the fetcher
51+ // Handle error returned from the fetcher here
52+
53+ // You can also handle cancellation with the following
54+ if (isReverificationCancelledError (err )) {
55+ // Handle the cancellation error here
56+ }
5857 }
5958 }
6059
0 commit comments