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

HomeView: Take advantage of ES7 decorators #74

Closed
kikoanis opened this issue Sep 13, 2015 · 1 comment
Closed

HomeView: Take advantage of ES7 decorators #74

kikoanis opened this issue Sep 13, 2015 · 1 comment

Comments

@kikoanis
Copy link

I know in HomeView, two components are exported for the sake of unit testing. But you still can take advantage of ES7 decorators which IMHO will get us to a cleaner code on the long run in more complicated scenarios.

So instead of

      export default connect(mapDispatchToProps)(HomeView);

create another class within the same file that inherits from HomeView but implements connect as a decorator. i.e.

        @connect(mapDispatchToProps)
        export default class ConnectedHomeView extends HomeView  {
        }

As export default is used anyway we won't have an issue with importing the connected one from the file

@dvdzkwsk
Copy link
Owner

Hmmmm, it used to use the decorator syntax up until I switched the exports up to export both the smart and dumb versions. The official Redux example uses the former (non-decorated) syntax, which is why I opted for it. I can see where you're coming from, as decorators are definitely the way to go, but I'm not entirely convinced it's that much cleaner in this scenario.

Thanks for the suggestion, I'll give it some thought. In the meantime, if you have any other compelling reasons for using the decorator syntax it's totally open for discussion.

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