Skip to content

Conversation

@zvictor
Copy link
Contributor

@zvictor zvictor commented Dec 2, 2016

Problem

I can't define the display-name of the middle container in some cases, having to stick with a MyContainer -> Container(MyComponent) -> MyComponent pattern.

screen shot 2016-12-02 at 14 06 29

Solution

Inspired by react-komposer-plus, the goal is to be able to define the display-name in the composers, as seen here. The pattern would then become MyContainer -> withRedux(MyComponent) -> MyComponent.

'ChildComponent';

Container.displayName = `Container(${childDisplayName})`; // eslint-disable-line
Container.displayName = `${displayName}(${childDisplayName})`; // eslint-disable-line
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we set: Container.displatName = displayName

@arunoda
Copy link
Owner

arunoda commented Dec 2, 2016

And I think this even possible:

Container = compose(...)
Container.displayName = 'something';

Are we trying to something else here?

@zvictor
Copy link
Contributor Author

zvictor commented Dec 2, 2016

It works well for components and containers, not for composers.

The following works:

Component = ...
Container.displayName = 'something';

Container = compose(myFn)(Component)
Container.displayName = 'something';

The following doesn't:

Component = ...

WithRedux = compose(myFn)
WithRedux.displayName = 'something'; // useless

WithTracker = compose(myFn)
WithTracker.displayName = 'something'; // useless

Composer = merge(
  WithRedux,
  WithTracker
)
Composer.displayName = 'something'; // useless

Container = Composer(Component)

When using merge an extra container is created with the name forced to be Container(...)

screen shot 2016-12-02 at 14 06 29

@arunoda
Copy link
Owner

arunoda commented Dec 5, 2016

But you could do this:

const Container = merge(
  WithRedux,
  WithTracker
)(Component);

Container.displayName = 'something';

@zvictor
Copy link
Contributor Author

zvictor commented Dec 5, 2016

Yes, I could. As I said, it works well for components and containers, not for composers.
This PR is about composers, not containers.

In your example there will be a something -> Container(InnerComponent) -> Component structure. I am not worried about the something occurrence, but the Container(InnerComponent).

@arunoda
Copy link
Owner

arunoda commented Dec 15, 2016

Okay. I am good to take this.
Could you add this feature to the README as well?
So, I could merge and this and do a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants