Skip to content

useOffsetPagination: reactive total option #3054

Closed Answered by lbineau
lbineau asked this question in Q&A
Discussion options

You must be logged in to vote

I'll answer my own question.
I've deep dived in the source code the expected type for total is a MaybeRef<number>
It seems useOffsetPagination total option is not reactive.

So the secret is to wrap the length as a Ref or a ComputedRef

export default {
  setup (props) {
    const placesLength = computed(() => props.location.length)
    const {
      currentPage,
      currentPageSize,
      pageCount
    } = useOffsetPagination({
      total: placesLength,
      page: 1,
      pageSize: 15
    })
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lbineau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant