Updates
This commit is contained in:
parent
c90843bbd1
commit
fcd69e55d4
@ -3,6 +3,7 @@ import React from "react";
|
||||
export type UseWebsocketHookParams = {
|
||||
debounce?: number;
|
||||
url: string;
|
||||
disableReconnect?: boolean;
|
||||
};
|
||||
|
||||
let reconnectInterval: any;
|
||||
@ -27,7 +28,7 @@ export const WebSocketEventNames = ["wsDataEvent", "wsMessageEvent"] as const;
|
||||
*/
|
||||
export default function useWebSocket<
|
||||
T extends { [key: string]: any } = { [key: string]: any }
|
||||
>({ url, debounce }: UseWebsocketHookParams) {
|
||||
>({ url, debounce, disableReconnect }: UseWebsocketHookParams) {
|
||||
const DEBOUNCE = debounce || 200;
|
||||
|
||||
const [socket, setSocket] = React.useState<WebSocket | undefined>(
|
||||
@ -73,6 +74,8 @@ export default function useWebSocket<
|
||||
};
|
||||
|
||||
ws.onclose = (ev) => {
|
||||
if (disableReconnect) return;
|
||||
|
||||
console.log("Websocket closed ... Attempting to reconnect ...");
|
||||
console.log("URL:", url);
|
||||
|
||||
|
@ -25,7 +25,7 @@ export default function Main() {
|
||||
>
|
||||
Contact Me
|
||||
</Button>
|
||||
<Button
|
||||
{/* <Button
|
||||
beforeIcon={
|
||||
<ScrollText size={17} className="font-normal" />
|
||||
}
|
||||
@ -34,7 +34,7 @@ export default function Main() {
|
||||
className="grow w-full"
|
||||
>
|
||||
Resume
|
||||
</Button>
|
||||
</Button> */}
|
||||
</Row>
|
||||
</Stack>
|
||||
</Section>
|
||||
|
Loading…
Reference in New Issue
Block a user