Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

do multiple composed containers using createEagerElementUtil result in more than one class-based container? #286

Closed
faceyspacey opened this issue Dec 9, 2016 · 1 comment

Comments

@faceyspacey
Copy link

faceyspacey commented Dec 9, 2016

I saw the talk about mapPropsStream eventually being used internally to do that. But it seems it's not currently implemented. It seems createEagerElementUtil will only do this for the first container:

https://github.com/acdlite/recompose/blob/master/src/packages/recompose/utils/createEagerElementUtil.js

if (!hasKey && isReferentiallyTransparent) {
    if (children) {
      return type({ ...props, children })
    }
    return type(props)
  }

After that, the wrapped functional component becomes a class and in further calls isReferentiallyTransparent will no longer be true, and therefore more wrappers than needed will be used.

To make this concrete, I'd like to be able to make the following usage of 2 containers result in one class container:

export default compose(
  withState('state1', 'setState1'),
  withState('state2', 'setState2')
)(Player)

For me that's a common case and I'm thinking of just making withStates that accepts an array and lets you provide more than one state to guarantee only one container class is used. But obviously that only would work for withState. Does anyone have a more general solution? Any idea on the status of the mapPropsStream solution?

@wuct
Copy link
Contributor

wuct commented Feb 28, 2017

Related to #182 and #308. I am going to close this issue since it can be discussed under those related issues. Feel free to reopen it.

@wuct wuct closed this as completed Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants