Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 2ecbbac

Browse files
authored
Refactor: Redirection changes build issue (#2784)
1 parent 3530e11 commit 2ecbbac

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/components/hooks/use-website-status.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,23 @@ export const useWebsiteStatusApi = () => {
6666
// Therefore we need a direct call from the API
6767
const [website_status_api, setWebsiteStatusApi] = useState(null)
6868

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+
}
7374

74-
binary_socket.onmessage = (msg) => {
75-
const response = JSON.parse(msg.data)
75+
binary_socket.onmessage = (msg) => {
76+
const response = JSON.parse(msg.data)
7677

77-
if (!response.error) {
78-
const { clients_country } = response.website_status
78+
if (!response.error) {
79+
const { clients_country } = response.website_status
7980

80-
setWebsiteStatusApi({ clients_country })
81+
setWebsiteStatusApi({ clients_country })
82+
}
83+
binary_socket.close()
8184
}
82-
binary_socket.close()
83-
}
85+
}, [website_status_api])
8486

8587
return website_status_api
8688
}

0 commit comments

Comments
 (0)