This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
features/Apiexplorer/SubscribeRenderer Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,12 @@ function SubscribeRenderer<T extends TSocketSubscribableEndpointNames>({
32
32
const [ is_not_valid , setIsNotValid ] = useState ( false ) ;
33
33
34
34
useEffect ( ( ) => {
35
- if ( error && error . code === 'AuthorizationRequired' ) {
35
+ if (
36
+ error &&
37
+ typeof error === 'object' &&
38
+ 'code' in error &&
39
+ error . code === 'AuthorizationRequired'
40
+ ) {
36
41
setToggleModal ( true ) ;
37
42
}
38
43
} , [ error ] ) ;
Original file line number Diff line number Diff line change @@ -6,15 +6,10 @@ import {
6
6
} from '@site/src/configs/websocket/types' ;
7
7
import { useCallback , useState } from 'react' ;
8
8
9
- type TError = {
10
- code ?: string ;
11
- message ?: string ;
12
- } ;
13
-
14
9
const useSubscription = < T extends TSocketSubscribableEndpointNames > ( name : T ) => {
15
10
const [ is_loading , setIsLoading ] = useState ( false ) ;
16
11
const [ is_subscribed , setSubscribed ] = useState ( false ) ;
17
- const [ error , setError ] = useState < TError > ( ) ;
12
+ const [ error , setError ] = useState < unknown > ( ) ;
18
13
const [ data , setData ] = useState < TSocketResponseData < T > > ( ) ;
19
14
const [ full_response , setFullResponse ] = useState < TSocketResponse < T > > ( ) ;
20
15
const [ subscriber , setSubscriber ] = useState < { unsubscribe ?: VoidFunction } > ( ) ;
@@ -30,7 +25,7 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T) =>
30
25
) ;
31
26
32
27
const onError = useCallback ( ( response : TSocketResponse < T > ) => {
33
- setError ( response . error ) ;
28
+ setError ( response ) ;
34
29
setIsLoading ( false ) ;
35
30
setFullResponse ( null ) ;
36
31
} , [ ] ) ;
You can’t perform that action at this time.
0 commit comments