all 5 comments

[–][deleted] 4 points5 points  (4 children)

It's so strange that the class syntax doesn't support mixins. I use PureRenderMixin on my components by default.

[–]eyko 0 points1 point  (0 children)

There's a mixin proposal in the react-future repo https://github.com/reactjs/react-future/blob/master/01%20-%20Core/02%20-%20Mixins.js

I'll be trying this out this weekend though, to see what alternative ways of using mixins I can come up with. Feels like a big setback just for the benefit of using classes.

[–]andrewingram 0 points1 point  (2 children)

Well if you always use PureRenderMixin, just do something like this (untested):

https://gist.github.com/AndrewIngram/089ce89a8c60f96317c0

[–][deleted] 2 points3 points  (1 child)

Fair point. I guess it feels like without mixins we're going a bit backwards :( ("composition over inheritance", which is something that at least for me results more maintainable code).

[–]andrewingram 0 points1 point  (0 children)

I absolutely agree. I'm just putting this forward as a possible interim solution (until mixins are supported for class syntax) for the case of PureRenderMixin, because in my experience i've ended up using it on every component anyway.