Tools and libraries

In the next section, we will go through some techniques, tools, and libraries that we can apply to our codebase to monitor and improve the performance.

Immutability

As we have seen, the most powerful tool we can use to improve the performance of our React application is the shouldComponentUpdate using the PureComponent.

The only problem is that the PureComponent uses a shallow comparison method against the props and state, which means that if we pass an object as a prop and we mutate one of its values, we do not get the expected behavior.

In fact, a shallow comparison cannot find mutation on the properties and the components never get re-rendered, except when the object itself changes.

One way to solve this issue is using immutable ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.