inertia icon indicating copy to clipboard operation
inertia copied to clipboard

[V2] Improve WhenVisible component to merge data and params props for a more flexible API

Open PedroAugustoRamalhoDuarte opened this issue 1 year ago • 0 comments

This PR fixes #2025

Enhancements

  • Merge data and params props:
    This PR introduces a more flexible API that merges the data and params props. Now, you can pass both in a single configuration like this:

    <WhenVisible fallback="Loading..." data={["todos", "pagy"]} params={{
      data: {
        teste: true,
        page: pagy.page + 1,
      },
      preserveUrl: true,
    }} />
    
  • Make children optional in WhenVisible:
    Which enhances use cases like InfiniteScroll. Here’s an example:

    <WhenVisible fallback="Loading..." params={{
      data: {
        page: pagy.page + 1,
      },
      only: ["todos", "pagy"],
      preserveUrl: true,
    }} />