This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -66,21 +66,23 @@ export const useWebsiteStatusApi = () => {
66
66
// Therefore we need a direct call from the API
67
67
const [ website_status_api , setWebsiteStatusApi ] = useState ( null )
68
68
69
- const binary_socket = BinarySocketBase . init ( )
70
- binary_socket . onopen = ( ) => {
71
- binary_socket . send ( JSON . stringify ( { website_status : 1 } ) )
72
- }
69
+ useLayoutEffect ( ( ) => {
70
+ const binary_socket = BinarySocketBase . init ( )
71
+ binary_socket . onopen = ( ) => {
72
+ binary_socket . send ( JSON . stringify ( { website_status : 1 } ) )
73
+ }
73
74
74
- binary_socket . onmessage = ( msg ) => {
75
- const response = JSON . parse ( msg . data )
75
+ binary_socket . onmessage = ( msg ) => {
76
+ const response = JSON . parse ( msg . data )
76
77
77
- if ( ! response . error ) {
78
- const { clients_country } = response . website_status
78
+ if ( ! response . error ) {
79
+ const { clients_country } = response . website_status
79
80
80
- setWebsiteStatusApi ( { clients_country } )
81
+ setWebsiteStatusApi ( { clients_country } )
82
+ }
83
+ binary_socket . close ( )
81
84
}
82
- binary_socket . close ( )
83
- }
85
+ } , [ website_status_api ] )
84
86
85
87
return website_status_api
86
88
}
You can’t perform that action at this time.
0 commit comments