React-apollo: Cannot compose withApollo()

Created on 22 Oct 2016  路  2Comments  路  Source: apollographql/react-apollo

When I try to compose withApollo() I get

graphql.js:37 Uncaught TypeError: Cannot read property 'displayName' of undefined

In getDisplayName function

function getDisplayName(WrappedComponent) {
    return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}

This does not work

export default compose(
  withApollo(),
  translate(),
  graphql(GET_SALON, {
    options: ownProps => ({
      variables: { slug: ownProps.params.slug },
    }),
  }),
)(Salon)

This works

export default compose(
  translate(),
  graphql(GET_SALON, {
    options: ownProps => ({
      variables: { slug: ownProps.params.slug },
    }),
  }),
)(withApollo(Salon))

Version

Most helpful comment

My 2cent, shouldn't it be

export default compose(
  withApollo, //no () after "withApollo"
  translate(),
  graphql(GET_SALON, {
    options: ownProps => ({
      variables: { slug: ownProps.params.slug },
    }),
  }),
)(Salon)

?

All 2 comments

My 2cent, shouldn't it be

export default compose(
  withApollo, //no () after "withApollo"
  translate(),
  graphql(GET_SALON, {
    options: ownProps => ({
      variables: { slug: ownProps.params.slug },
    }),
  }),
)(Salon)

?

@svrcekmichal you're right, thanks! Stupid mistake ...

Was this page helpful?
0 / 5 - 0 ratings