DEV Community

Discussion on: Pagination in Javascript and React, with a custom usePagination() hook

Collapse
damiisdandy profile image
damilola jerugba Author

usePaginationReturn is an interface for an object not a function.


type UsePagination = (UsePaginationProps) => (UsePaginationReturn);
const usePagination: UsePagination = ({ contentPerPage, count }) => {  /*...*/ }

Enter fullscreen mode Exit fullscreen mode

The above type is the correct implementation.

Collapse
harryheman profile image
Igor Agapov

usePaginationReturn is an interface for an object, returning from a function, so this

type UsePagination = (UsePaginationProps) => (UsePaginationReturn);
const usePagination: UsePagination = ({ contentPerPage, count }) => {  /*...*/ }
Enter fullscreen mode Exit fullscreen mode

is equivalent to this

const usePagination = ({ contentPerPage, count }: UsePaginationProps): UsePaginationReturn => { /* ... */ }
Enter fullscreen mode Exit fullscreen mode

Just -1 type