Container and Presentational pattern

In the last chapter, we saw how to take a coupled component and make it reusable step by step.

In this section, we will see how to apply a similar pattern to our components to make them more clean and maintainable.

React components typically contain a mix of logic and presentation.

By logic, we refer to anything that is unrelated to the UI, such as API calls, data manipulation, and event handlers.

The presentation is, instead, the part inside the render method where we create the elements to be displayed on the UI.

In React, there is a simple and powerful pattern, known as Container and Presentational, which we can apply when creating components that help us to separate those two concerns.

Creating well-defined boundaries ...

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.