Maintain websocket activity on sendConnection

This commit is contained in:
Nishad 2020-09-05 07:53:18 +08:00
parent 841fbf3702
commit b212e84d53
1 changed files with 14 additions and 1 deletions

View File

@ -41,9 +41,22 @@ export function ConnectionProvider({ children }) {
useEffect(() => {
const id = connection.onSlotChange(() => null);
return () => clearInterval(id);
return () => connection.removeSlotChangeListener(id);
}, [connection]);
useEffect(() => {
const id = sendConnection.onAccountChange(
new Account().publicKey,
() => {},
);
return () => sendConnection.removeAccountChangeListener(id);
}, [sendConnection]);
useEffect(() => {
const id = sendConnection.onSlotChange(() => null);
return () => sendConnection.removeSlotChangeListener(id);
}, [sendConnection]);
return (
<ConnectionContext.Provider
value={{ endpoint, setEndpoint, connection, sendConnection }}