Infinite scroll
Merge pages of items and report paging metadata to the InfiniteScroll client component.
Scroll(...) merges the items inside a value (the wrapper, "data" by default) and reports paging metadata to the <InfiniteScroll> client component.
The client
Metadata
ScrollMetadata(PageName, PreviousPage, NextPage, CurrentPage) is a record. Page values can be int, long, string or null (cursor paging uses strings).
Metadata comes from the metadata: argument, or from the value if it implements IProvidesScrollMetadata. Without either, the render throws with a message naming the prop.
The client sends X-Inertia-Infinite-Scroll-Merge-Intent: prepend when scrolling up. The wrapper is then reported under prependProps instead of mergeProps.
scrollProps[path].reset is true when the request lists the path in X-Inertia-Reset.
Combining with other props
Scroll(...) accepts the five loader shapes, and .Defer(), .Once() and .Rescue() combine with it:
A deferred scroll prop reports "posts.data" just like a resolved one. This is a deliberate fix of an inertia-laravel quirk.
Keep pages small
Infinite scroll is also a payload-size tool. Load 10 to 20 items per page instead of sending an unbounded list on the first request.