[英]resetting a pagination to refetch on default variables on pull to refresh throw cursor warning?
i have this props on my flatlist:我的平面清单上有这个道具:
onRefresh={() => {
setIsRefreshing(true);
refetch(
{ categoriesCount: 4, categoriesCursor: '' },
{
fetchPolicy: 'network-only',
onComplete: () => {
setIsRefreshing(false);
},
}
);
}}
this is how i initialize pagination:这就是我初始化分页的方式:
const { data, loadNext, isLoadingNext, hasNext, refetch } = usePaginationFragment<
CategoriesPaginationQuery,
Categories_viewer$key
>(
graphql`
fragment Categories_viewer on Viewer
@argumentDefinitions(
categoriesCount: { type: "Int", defaultValue: 4 }
categoriesCursor: { type: "String", defaultValue: "" }
)
@refetchable(queryName: "CategoriesPaginationQuery") {
categories(first: $categoriesCount, after: $categoriesCursor)
@connection(key: "Categories_viewer_categories", filters: []) {
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
edges {
cursor
node {
id
pk
name
}
}
}
}
`,
viewer
);
this is the warning:这是警告:
Warning: Relay: Unexpected after cursor ``, edges must be fetched from the end of the list (YXJyYXljb25uZWN0aW9uOjc=).
警告:中继:在 cursor 之后出现意外,必须从列表末尾获取边 (YXJyYXljb25uZWN0aW9uOjc=)。
you see on the argumentDefinitions the default value of categoriesCount is 4 and categoriesCursor is "" and i think relay thinks i am reusing variables that's already fetched but what i want to do is make the pagination "forget it's current edges" and go back like the beginning on pull to refresh?您在 argumentDefinitions 上看到 categoriesCount 的默认值是 4,categoriesCursor 是“”,我认为中继认为我正在重用已经获取的变量,但我想做的是让分页“忘记它的当前边缘”和 go 像开始拉刷新?
To refetch a pagination container, use refetchConnection
.要重新获取分页容器,请使用
refetchConnection
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.