Commit cbccdb9f authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Wrap callback in useCallback to avoid extra re-renders

parent aaaa7396
import { IconButton, RefreshIcon } from '@hypothesis/frontend-shared/lib/next'; import { IconButton, RefreshIcon } from '@hypothesis/frontend-shared/lib/next';
import { useEffect } from 'preact/hooks'; import { useCallback, useEffect } from 'preact/hooks';
import { useShortcut } from '../../shared/shortcut'; import { useShortcut } from '../../shared/shortcut';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
...@@ -20,7 +20,10 @@ function PendingUpdatesButton({ ...@@ -20,7 +20,10 @@ function PendingUpdatesButton({
const store = useSidebarStore(); const store = useSidebarStore();
const pendingUpdateCount = store.pendingUpdateCount(); const pendingUpdateCount = store.pendingUpdateCount();
const hasPendingUpdates = store.hasPendingUpdates(); const hasPendingUpdates = store.hasPendingUpdates();
const applyPendingUpdates = () => streamer.applyPendingUpdates(); const applyPendingUpdates = useCallback(
() => streamer.applyPendingUpdates(),
[streamer]
);
useShortcut('l', () => hasPendingUpdates && applyPendingUpdates()); useShortcut('l', () => hasPendingUpdates && applyPendingUpdates());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment