In V7, how to use Transformer with pagination in inertia? how to generate page props #5050
Answered
by
airiechamorro
tsulatsitamim
asked this question in
Help
-
|
In V7, how to use Transformer with pagination in inertia? how to generate page props |
Beta Was this translation helpful? Give feedback.
Answered by
airiechamorro
Feb 25, 2026
Replies: 1 comment 1 reply
-
|
I use this PaginatedProp generic in my v7 projects export type PaginationMetadata = {
total: number;
per_page: number;
current_page: number;
last_page: number;
first_page: number;
first_page_url: string | null;
last_page_url: string | null;
next_page_url: string | null;
previous_page_url: string | null;
};
/**
* Paginated prop type for Inertia pages
*
* Represents a paginated result from Transformer.paginate().
* Contains the data array and pagination metadata.
*
* @template T - The type of items in the data array
*
* @example
* ```tsx
* import type { PaginatedProp, Data } from '~/types'
*
* type Props = {
* users: PaginatedProp<Data.User>
* }
*
* export default function UsersIndex({ users }: Props) {
* return (
* <div>
* {users.data.map(user => (
* <div key={user.id}>{user.name}</div>
* ))}
* <p>Page {users.metadata.current_page} of {users.metadata.last_page}</p>
* </div>
* )
* }
* ```
*/
export type PaginatedProp<T> = {
data: T[];
metadata: PaginationMetadata;
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
tsulatsitamim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this PaginatedProp generic in my v7 projects