stampit-org / react-stamp

Composables for React.
370 stars 10 forks source link

Automatically setting displayName for a component #40

Open danielkcz opened 8 years ago

danielkcz commented 8 years ago

Just an idea, I'm not sure if it doesn't collide with something else at this point, but what about defining component like this:

const MyComponent = () => ({
    render() {
    }
});
export default ReactStamp.compose(
    MyComponent, Focusable, Emittable
);

It means that it would have to call passed function to a compose to obtain a descriptor. Along the way it would be possible to read displayName of that function and append into final descriptor. I also like it this way as final composition is more readable.

troutowicz commented 8 years ago

I am definitely on board with automatically setting displayName. Feel free to propose changes in a PR.