我从https://github.com/facebook/relay/blob/master/packages/react-relay/modern/ReactRelayPaginationContainer.js阅读并https://facebook.github.io/relay/docs/pagination-container.html即使有更多的项目,我不能做继电器loadMore?
我的计数变量是工作,我想我已经正确设置它,但我不能loadMore项目,我hasMore是假的,这意味着我没有更多的待办事项到display.This是我的代码:
export default createPaginationContainer(TodoList,
{
viewer: graphql`
fragment TodoList_viewer on User {
todos(
first: $count #
) @connection(key: "TodoList_todos") {
edges {
node {
id,
complete,
...Todo_todo,
},
},
},
id,
totalCount,
completedCount,
...Todo_viewer,
}
`,
},
{
direction: 'forward',
getConnectionFromProps(props) {
console.log("getConnectionFromProps props ",props)
return props.viewer && props.viewer.todos;
},
getFragmentVariables(prevVars, totalCount) {
console.log("getFragmentVariables total count ",totalCount)
return {
...prevVars,
count: totalCount, // the total of displayed todos on the fragment
};
},
getVariables(props, {count}, fragmentVariables) {
console.log("getVariables count ",count)
return {
count,
// cursor,
// in most cases, for variables other than connection filters like
// `first`, `after`, etc. you may want to use the previous values.
// orderBy: fragmentVariables.orderBy,
};
},
query: graphql`
query TodoListPaginationQuery(# assign component name + Pagination + Query
$count: Int!
) {
viewer {
# You could reference the fragment defined previously.
...TodoList_viewer
}
}
`
});
我不知道我在做什么错在这里。也许如果你知道这个工作示例(我在github中找不到),我将非常感谢
我explecitly所有在pageInfo,hasNextPage是真实的,但但this.props.relay.hasMore()返回false –