I want to use fetchMore when handleLoadMore is called to get 10 data from the 11th one, but the data in console.log(data) is from 0 to 10, which is the first data I got.
I tried to open the DevTool network, but the network shows data from 11.
import {
Box,
Button,
} from '@chakra-ui/react'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { useState } from 'react'
import { ChannelLayout } from '@/components/Layouts/ChannelLayout'
import { useFindMyMoviesQuery } from '@/generated/request'
import type { NextPageWithLayout } from '@/types/layout'
const Cannel: NextPageWithLayout = () => {
const router = useRouter()
const { data, loading, fetchMore } = useFindMyMoviesQuery({
variables: { skip: 0, take: 10 },
})
const [currentPage, setCurrentPage] = useState(1)
console.log(data)
if (loading) return loading...
const handleLoadMore = () => {
const pageSize = 10
fetchMore({
variables: {
skip: 11,
take: 10,
},
}).then((result) => {
setCurrentPage(page)
})
}
return (
)
}
Cannel.getLayout = ChannelLayout
export default Cannel
As noted above.
0 comments:
Post a Comment
Thanks