【问题标题】:Relay pagination(Not infinite scroll)中继分页(不是无限滚动)
【发布时间】:2016-11-13 16:22:19
【问题描述】:

我正在尝试在没有无限滚动的情况下编写分页代码。我希望能够单击页码并相应地更新前后光标。当该页上最后一条记录的光标。我不确定这是否是解决此问题的最佳方法。第一次用继电器。我不确定如何根据条件动态更改容器。有时我不会有之后或之前。我正在传递空字符串,但中继抱怨 graphql 查询工具没有。

1] Warning: GraphQLRange cannot find a segment that has the cursor:
[1] GraphQLRange cannot find a segment that has the cursor:

export default Relay.createContainer(Search,{
  initialVariables: {
    pageSize: 20,
    lastRecord:""

  },
  fragments: {
    Viewer: () => Relay.QL`
      fragment on Viewer {
          User_Email,
     Books (first: $pageSize, after: $lastRecord) {
              totalCount
              pageInfo {
                hasNextPage
                hasPreviousPage
                startCursor,
                endCursor
              }
              edges{
              cursor,
              node{
                  Title,

                  id,
                  Pub_Date,

                }
              }
            }
      }
    `
  }
});

这是一个好方法吗?有没有其他人试图这样做。你读到的每一篇关于中继分页的文章都是无限滚动的。

【问题讨论】:

    标签: javascript pagination graphql relayjs


    【解决方案1】:

    为避免此错误,请将 lastRecord 变量设置为 null 而不是空字符串。

        initialVariables: {
          pageSize: 20,
          lastRecord:null
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 2014-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多