Skip to content

Commit

Permalink
fix: move up initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn committed Aug 14, 2023
1 parent 0b27541 commit 7e0e082
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { useMeasure, useMedia } from 'react-use';
import {
getPeersWithTiles,
Expand Down Expand Up @@ -30,6 +30,7 @@ export function EqualProminence() {
const [pagesWithTiles, setPagesWithTiles] = useState([]);
const [page, setPage] = useState(0);
const [ref, { width, height }] = useMeasure();
const peersSorter = useMemo(() => new PeersSorter(vanillaStore), [vanillaStore]);
const pageSize = pagesWithTiles[0]?.length;

useEffect(() => {
Expand Down Expand Up @@ -127,17 +128,12 @@ export function EqualProminence() {
if (page !== 0) {
return;
}
const peersSorter = new PeersSorter(vanillaStore);
peersSorter.setPeersAndTilesPerPage({
peers,
tilesPerPage: pageSize || maxTileCount,
});
peersSorter.onUpdate(setSortedPeers);

return () => {
peersSorter.stop();
};
}, [page, vanillaStore, peers, pageSize, maxTileCount]);
}, [page, peersSorter, peers, pageSize, maxTileCount]);

return (
<Flex direction="column" css={{ flex: '1 1 0', h: '100%', position: 'relative', minWidth: 0 }}>
Expand Down

0 comments on commit 7e0e082

Please sign in to comment.