allenai / pdf-component-library

51 stars 5 forks source link

29467 Reduce unnecessary re-renders with useCallback #39

Closed carolinepaulic closed 3 years ago

carolinepaulic commented 3 years ago

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 and HighlightOverlay that I will add callbacks to once computeStyleWithContext is refactored (another subtask in the loose ends ticket).

Testing Plan