mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
fixes
This commit is contained in:
@@ -14,12 +14,12 @@ export function SocketProvider({ children, options, url }: SocketProviderProps)
|
||||
const [ socket, setSocket ] = useState<Socket | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const s = new Socket(url, options);
|
||||
s.connect();
|
||||
setSocket(s);
|
||||
const socketInstance = new Socket(url, options);
|
||||
socketInstance.connect();
|
||||
setSocket(socketInstance);
|
||||
|
||||
return () => {
|
||||
s.disconnect();
|
||||
socketInstance.disconnect();
|
||||
setSocket(null);
|
||||
};
|
||||
}, [ options, url ]);
|
||||
@@ -34,7 +34,7 @@ export function SocketProvider({ children, options, url }: SocketProviderProps)
|
||||
export function useSocket() {
|
||||
const context = React.useContext(SocketContext);
|
||||
if (context === undefined) {
|
||||
throw new Error('useCount must be used within a SocketProvider');
|
||||
throw new Error('useSocket must be used within a SocketProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
|
||||
const onCloseRef = useRef<string>();
|
||||
const onErrorRef = useRef<string>();
|
||||
|
||||
const onJoinFun = useRef(onJoin);
|
||||
onJoinFun.current = onJoin;
|
||||
const onJoinRef = useRef(onJoin);
|
||||
onJoinRef.current = onJoin;
|
||||
|
||||
useEffect(() => {
|
||||
const cleanUpRefs = () => {
|
||||
@@ -31,7 +31,7 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
|
||||
|
||||
if (!isDisabled) {
|
||||
onCloseRef.current = onSocketClose && socket?.onClose(onSocketClose);
|
||||
onErrorRef.current = onSocketError && socket?.onClose(onSocketError);
|
||||
onErrorRef.current = onSocketError && socket?.onError(onSocketError);
|
||||
} else {
|
||||
cleanUpRefs();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
|
||||
}
|
||||
|
||||
const ch = socket.channel(topic, params);
|
||||
ch.join().receive('ok', (message) => onJoinFun.current?.(ch, message));
|
||||
ch.join().receive('ok', (message) => onJoinRef.current?.(ch, message));
|
||||
setChannel(ch);
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -3,8 +3,8 @@ import { useEffect, useRef } from 'react';
|
||||
import type { SocketMessageParams } from 'lib/socket/types';
|
||||
|
||||
export default function useSocketMessage({ channel, event, handler }: SocketMessageParams) {
|
||||
const handlerFun = useRef(handler);
|
||||
handlerFun.current = handler;
|
||||
const handlerRef = useRef(handler);
|
||||
handlerRef.current = handler;
|
||||
|
||||
useEffect(() => {
|
||||
if (channel === undefined) {
|
||||
@@ -12,7 +12,7 @@ export default function useSocketMessage({ channel, event, handler }: SocketMess
|
||||
}
|
||||
|
||||
const ref = channel.on(event, (message) => {
|
||||
handlerFun.current?.(message);
|
||||
handlerRef.current?.(message);
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -48,7 +48,7 @@ const TransactionPageContent = () => {
|
||||
return <ExternalLink key={ explorer.baseUrl } title={ `Open in ${ explorer.title }` } href={ url.toString() }/>;
|
||||
});
|
||||
|
||||
const hasGoBackLink = false && isBrowser() && window.document.referrer.includes('/txs');
|
||||
const hasGoBackLink = isBrowser() && window.document.referrer.includes('/txs');
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
||||
Reference in New Issue
Block a user