If you work in React projects, you’ve probably seen this:
Long blocks of code that use many variables and allow complex execution paths. In short, React components are doing way more than they should.
Putting together pieces of code that perform distinct tasks is a problem because it inhibits code reusability, makes testing difficult, and increases the time required to understand the code.
Solution? The Single Responsibility Principle.
Read this ebook to see how following the Single Responsibility Principle allows building a React codebase that is easy to understand and ready for changes. To show you how it works in practice, we are going to refactor a fat React component into smaller pieces, each with its very own, single responsibility.