Extracting Logic from React Components

Article by Jack Franklin

By looking through our components and finding standalone functions that we can pull out, we greatly simplify our component whilst increasing our test coverage and clarity of our application greatly. By pulling the functions into their own modules you are forced to consider which props are needed and how your function will work. It makes code clearer, it's easier to see which props are used where and it means as your business logic gets more complex you can test it without having to get your UI components involved.


Related resources

Compound React Components with Hooks + TypeScript

When writing React components, it always pays off to spend a little bit of time thinking about how another developer would use them. In this post, I'd like to dive a bit into Compound Components, a pattern for creating components that I've found to be a joy to use both as a creator and consumer. We'll [continue]

Tutorial by Martin Di Diego

Learn React By Making a Countdown Timer

This guide aims to help those familiar with DOM manipulation with jQuery to learn and transition to coding in React. We will be building a countdown timer in React and comparing it to a functionally similar version built with jQuery. [continue]

Tutorial by codethesite

How To Master Advanced React Design Patterns: Compound Components

To celebrate the official release of React 16.3, I have decided to share some techniques I have been using recently which have completely changed my approach to creating React components. Using these techniques I am able to design components that are completely reusable, and have the flexibility to use [continue]

Tutorial by Shaun David Hutch

Handling spacing in a UI component library

Building a highly consumable UI component library is no easy feat and this article will focus on one particular tricky aspect of it: outer component spacing. [continue]

Article by Chris Pearce