question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recompose `compose` error if more than 8 HOCs

See original GitHub issue

If there are more than 8 HOCs used per one compose, I get the following error:

Error: src/components/Checkout/index.js:68
       v-------
 68:   compose(
 69:     setDisplayName('Checkout'),
 70:     withState('isLoading', 'setLoading', false),
...:
163:   )(Component);
       ^ function call. Function cannot be called on any member of intersection type
 68:   compose(
       ^^^^^^^ intersection
  Member 1:
                                 v---------------------------
   74:   declare type Compose = (<A, B, C, D, E, F, G, H, I>(
   75:     hi: UnaryFn<H, I>,
   76:     gh: UnaryFn<G, H>,
  ...:
   84:   ) => UnaryFn<A, I>) &
         -----------------^ polymorphic type: function type. See lib: flow-typed/npm/recompose_v0.24.x.js:74
  Error:
   81:     withState('dimensions', 'setDimensions', { width: -1, height: -1 })
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. This type is incompatible with
   83:     ...rest: Array<void>
                          ^^^^ undefined. See lib: flow-typed/npm/recompose_v0.24.x.js:83
...

I assume it’s because in type definitions of compose there is Array<void> used:

declare type Compose = (<A, B, C, D, E, F, G, H, I>(
    hi: UnaryFn<H, I>,
    gh: UnaryFn<G, H>,
    fg: UnaryFn<F, G>,
    ef: UnaryFn<E, F>,
    de: UnaryFn<D, E>,
    cd: UnaryFn<C, D>,
    bc: UnaryFn<B, C>,
    ab: UnaryFn<A, B>,
    ...rest: Array<void>
  ) => UnaryFn<A, I>) &
  (<A, B, C, D, E, F, G, H>(
    gh: UnaryFn<G, H>,
    fg: UnaryFn<F, G>,
    ef: UnaryFn<E, F>,
    de: UnaryFn<D, E>,
    cd: UnaryFn<C, D>,
    bc: UnaryFn<B, C>,
    ab: UnaryFn<A, B>,
    ...rest: Array<void>
  ) => UnaryFn<A, H>) &
  (<A, B, C, D, E, F, G>(
    fg: UnaryFn<F, G>,
    ef: UnaryFn<E, F>,
    de: UnaryFn<D, E>,
    cd: UnaryFn<C, D>,
    bc: UnaryFn<B, C>,
    ab: UnaryFn<A, B>,
    ...rest: Array<void>
  ) => UnaryFn<A, G>) &
    (<A, B, C, D, E, F>(
      ef: UnaryFn<E, F>,
      de: UnaryFn<D, E>,
      cd: UnaryFn<C, D>,
      bc: UnaryFn<B, C>,
      ab: UnaryFn<A, B>,
      ...rest: Array<void>
    ) => UnaryFn<A, F>) &
    (<A, B, C, D, E>(
      de: UnaryFn<D, E>,
      cd: UnaryFn<C, D>,
      bc: UnaryFn<B, C>,
      ab: UnaryFn<A, B>,
      ...rest: Array<void>
    ) => UnaryFn<A, E>) &
    (<A, B, C, D>(
      cd: UnaryFn<C, D>,
      bc: UnaryFn<B, C>,
      ab: UnaryFn<A, B>,
      ...rest: Array<void>
    ) => UnaryFn<A, D>) &
    (<A, B, C>(
      bc: UnaryFn<B, C>,
      ab: UnaryFn<A, B>,
      ...rest: Array<void>
    ) => UnaryFn<A, C>) &
    (<A, B>(ab: UnaryFn<A, B>, ...rest: Array<void>) => UnaryFn<A, B>)

If I replace void with Function, everything becomes fine.

If someone can clarify this issue? Perhaps I’m misunderstanding something? Thanks.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
mwalkerwellscommented, Aug 14, 2017

Yep, correct. You can also nest composes within composes and extend unbounded.

1reaction
mwalkerwellscommented, Aug 14, 2017

Cover the whole alphabet if you think the use cases are there. 😛

declare type Compose = (<A, B, C, D, E, F, G, H, I>( //...

https://github.com/flowtype/flow-typed/blob/master/definitions/npm/recompose_v0.24.x/flow_v0.47.x-/recompose_v0.24.x.js#L71

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recompose `compose` error if more than 8 HOCs · Issue #1115 ...
If there are more than 8 HOCs used per one compose, I get the following error: Error: src/components/Checkout/index.js:68 v------- 68: compose( 69: ...
Read more >
Using Recompose to write clean higher-order components
Learn how Recompose methods can help create cleaner HOCs and how it simplifies the development and organization of React components.
Read more >
reactjs - testing multiple HOC composed with recompose
testing this logic is proving difficult. The project I am working on is using react-test-renderer and utilising the shallow render method. So ...
Read more >
Using Recompose to build higher-order components - BigBinary
Recompose allows us to write many smaller higher-order components and ... If the predicate evaluates to true then the left HOC is rendered ......
Read more >
Replacing Recompose with React Hooks - Rainforest QA
After more than three years of working with it, we've identified a lot of ... shipped with React v16.8 and provided an alternative...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found