As far as I am aware there are two ways to create and export a react class using ES6.
Maybe considered the old way:
export default React.createClass({
...
});
Maybe considered the new way:
export class Todo extends React.Component {
...
};
I was asked today why I prefer the 'old' way compared to the 'new' way. I didn't really have a good answer apart from the fact that the 'new' way uses extends, and as a result, inheritance. I was taught in c# to always favour composition over inheritance. And in javascript the same, preferring to use the revealing module pattern over prototypical inheritance for 95% of cases.
Being fairly new to react, my question is, am I missing something to why the new way is better than the old way? In my eyes it is far cleaner to have a function that accepts parameters and returns an object compared to inheriting from one.
Would it maybe not be nicer to follow a conversion, TodoComponent, maybe, or add some sort of decorator rather then extending from React.Component?