我從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 –