Fix/945: Orderbook memory leak (#978)

* fix: cancel throttle on unmount

* fix: format

* fix: lint
This commit is contained in:
botond 2022-08-09 14:31:56 +01:00 committed by GitHub
parent 9a2ac6a8ac
commit 25c3ac8b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,6 +83,7 @@ export const OrderbookManager = ({ marketId }: OrderbookManagerProps) => {
});
useEffect(() => {
const throttleRunnner = updateOrderbookData.current;
if (!data) {
dataRef.current = { rows: null };
setOrderbookData(dataRef.current);
@ -94,6 +95,10 @@ export const OrderbookManager = ({ marketId }: OrderbookManagerProps) => {
...mapMarketData(data.data, resolution),
};
setOrderbookData(dataRef.current);
return () => {
throttleRunnner.cancel();
};
}, [data, resolution]);
useEffect(() => {