Open PedroAugustoRamalhoDuarte opened 1 month ago
Hi! I have the problem too! I want to set data to my feed and use params to manage the currentPage number update but it doesn't work.
When using params
, the data
actually should be optional. Right now it doesn't.
As a temporal fix, you can set the data prop as an empty string and Inertia will use the params
prop
<WhenVisible fallback={"Loading..."} data={''} params={{
data: {
teste: true,
page: pagy.page + 1,
},
preserveUrl: true,
only: ["todos", "pagy"]
}} />
Versions:
@inertiajs/react
version: v2-betaDescribe the problem:
In the current implementation of the
WhenVisible
component, it is not possible to use both data andparams
props simultaneously. The issue lies in thegetReloadParams
function, which either returns data or params but not both. To provide a more flexible and user-friendly API, it would be ideal to merge the data prop into params when both are provided.Steps to reproduce:
Actual code
https://github.com/inertiajs/inertia/blob/88a765b3a3736a63b6619863b9bd872a5327f0d6/packages/react/src/WhenVisible.ts#L24
Expected behavior:
When both data and params are provided, the function should merge them into a single object, allowing both to work together.
A initial implementation for React can be something like: