This PR aims to reduce unnecessary re-renders by wrapping functions that use hooks with useCallback.
Reviewer Instructions
Let me know if you see any places I missed or any functions that I wrapped in a callback where it wasn't needed. There are a couple places in BoundingBox and HighlightOverlay that I will add callbacks to once computeStyleWithContext is refactored (another subtask in the loose ends ticket).
Testing Plan
Existing functionality works as expected: zoom in/out, rotate CW/CCW, outline (open, scroll to page, close), highlight overlay demo, text highlight demo, scroll to demo
Description
This is a subtask of https://github.com/allenai/scholar/issues/28926, originally split out from the state management work in https://github.com/allenai/scholar/issues/28332 based on the following feedback:
This PR aims to reduce unnecessary re-renders by wrapping functions that use hooks with
useCallback
.Reviewer Instructions
Let me know if you see any places I missed or any functions that I wrapped in a callback where it wasn't needed. There are a couple places in
BoundingBox
andHighlightOverlay
that I will add callbacks to oncecomputeStyleWithContext
is refactored (another subtask in the loose ends ticket).Testing Plan