UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

14 lines (13 loc) 607 B
import { useEvent } from "@1771technologies/lytenyte-core/internal"; import { equal } from "@1771technologies/lytenyte-shared"; export function useOnViewChange(source, requestsForView, setRequestsForView) { const onViewChange = useEvent((bounds) => { // This will result in the server sending the requests for the current view. source.rowViewBounds = [bounds.rowCenterStart, bounds.rowCenterEnd]; const requests = source.requestsForView(); if (equal(requests, requestsForView)) return; setRequestsForView(requests); }); return onViewChange; }