Make sure view count fetch runs when claim ID changes. (#617)

This commit is contained in:
Dan Peterson 2022-01-04 12:40:31 -06:00 committed by GitHub
parent b0dbdeae27
commit 5cf78e792b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,12 +17,11 @@ type Props = {
function FileViewCount(props: Props) { function FileViewCount(props: Props) {
const { claimId, fetchViewCount, viewCount, livestream, activeViewers, isLive = false } = props; const { claimId, fetchViewCount, viewCount, livestream, activeViewers, isLive = false } = props;
// @Note: it's important this only runs once on initial render.
React.useEffect(() => { React.useEffect(() => {
if (claimId) { if (claimId) {
fetchViewCount(claimId); fetchViewCount(claimId);
} }
}, []); // eslint-disable-line react-hooks/exhaustive-deps }, [claimId]); // eslint-disable-line react-hooks/exhaustive-deps
const formattedViewCount = Number(viewCount).toLocaleString(); const formattedViewCount = Number(viewCount).toLocaleString();