无法读取undefined的属性'bind'

时间:2018-05-21 18:19:35

标签: redux react-redux apollo react-apollo

操作系统:Windows 10 Pro
apollo-client:1.9.2
react-redux:5.0.6

所以,我试图将graphql结果集'connect'读到redux,但是我收到了上面提到的错误消息。我的代码如下:

import { connect } from 'react-redux';

class PhotoGrid extends React.Component {
  render () {
    const { data } = this.props;
    const isNewPage = this.props.location.pathname.includes('new');
    
    if (data.loading) {
      return <p>Loading ...</p>;
    }
    if (data.error) {
      return <p>{data.error.message}</p>;
    }
    return (
      <div>
        <div>Total record count: {data._allPostsesMeta.count}</div>
        <div className="photo-grid">
          { data.allPostses.map( (post,i) => <Photo {...this.props} key={i} postIndexID={i} post={post} />) }
        </div>
        {isNewPage && (
          <div>
            <div onClick={() => this.previousPage()}>
              Previous
            </div>
            <div onClick={() => this.nextPage()}>
              Next
            </div>
          </div>
        )}
      </div>
    );
  }
};

const allPostsCommentsQuery = graphql(All_Posts_Comments_Query, {
  options: ownProps => {
    const page = parseInt(ownProps.match.params.page, 10);
    const isNewPage = ownProps.location.pathname.includes('new');
    const skip = isNewPage ? (page - 1) * parseInt(PRODUCTS_PER_PAGE) : 0;
    const first = isNewPage ? parseInt(PRODUCTS_PER_PAGE) : parseInt(PRODUCTS_PER_PAGE);
    const orderBy = isNewPage ? OrderBy : null;
    fetchPolicy: 'network-only';
    
    return {
      variables: { 
        __offline__: true,
        first,
        skip,
        orderBy, 
      },
    }
  },
});

export default connect(allPostsCommentsQuery)(PhotoGrid)

我在这里俯瞰什么?

0 个答案:

没有答案