react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

V4 -- Provide ability to use PureComponent as base class #264

Closed weblogixx closed 8 years ago

weblogixx commented 8 years ago

As seen in https://github.com/facebook/react/releases/tag/v15.3.0, we now have to possibility to use the following pattern with es2015 classes:

class MyComponent extends React.PureComponent {
....
}

This will eliminate the need to handle shouldComponentUpdate by yourself or stateless functional components if you want to.

We should allow the user to extend from React.PureComponent, e.g. as a command line flag.

@sthzg: Whats your opinion on this?

sthzg commented 8 years ago

👍 that would be a great addition, especially as it is a core feature without an external dependency now.

weblogixx commented 8 years ago

We could build this on your current refactorings, maybe as its own style (stateless vs statefull vs cssmodulearized?). Or do you think it would be better to just wrap the current templates with ejs ifs?

sthzg commented 8 years ago

I thought about this. IMO that's a good match for an if/else, as the condition only affects one token in the class extends line.

weblogixx commented 8 years ago

If you are not already working on this, I would include this feature tomorrow

sthzg commented 8 years ago

Haven't started work on this issue. If you have time and want to tackle it then that's great, otherwise feel free to assign me on it.

weblogixx commented 8 years ago

Sorry, I cannot, we`ll have to wait for the move first. Will do this tomorrow. Seems like a good place to start again ;).

weblogixx commented 8 years ago

Just added this in https://github.com/react-webpack-generators/generator-react-webpack/commit/4f9488cb9951d670ceb2074a469c19e64b3b5d69. Seems to work ok. Tests are getting more and more with every option we might add to the component generator. Maybe I should look more into testing here, as the style type approach does not differ that much (only the import style type filename is different).

sthzg commented 8 years ago

👍 nice, and still no if-stmt in the templates. :-) Looking into the tests sounds reasonable, maybe in a separate issue to get this feature in quicker?

weblogixx commented 8 years ago

Yes, would think so, too. We should also think about adding coverage to the project (at least as a nice to have).