Optimization techniques

It is important to notice that, in all the examples in this book, we are using apps that have either been created with create-react-app or have been created from scratch, but always with the development version of React.

Using the development version of React is very useful for coding and debugging as it gives you all the necessary information to fix the various issues. However, all the checks and warnings come with a cost which we want to avoid in production.

So, the very first optimization that we should do to our applications is to build the bundle setting the NODE_ENV environment variable to production. This is pretty easy with Webpack and it is just a matter of using the DefinePlugin in the following way:

new webpack.DefinePlugin({ ...

Get React Design Patterns and Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.