This excellent post by Lucas Reis introduces various patterns for writing React components.
I’ve been writing React applications for a few years now, and I’ve noticed that some patterns tend to repeat themselves. In this post, I’ll review these patterns which will summarize about 99% of the React code I write every day.
As someone who writes a lot of React code, this is a great summary of common patterns. React does not need to be complicated. Vanilla components and the Container/Component Pattern comprise of most of my React development.
Lucas also presents the concepts of Higher Order Components and Render Props effectively:
Regular React components work well most of the time, but it’s better to try separating logic from view. If you need to reuse logic for different view components, use HOCs or Render Props. If the logic involves expensive side effects that should only run once, use a provider.
If you want to learn more about Render Props, I recommend watching the article, “Never Write another HOC” by Michael Jackson, creator of React Router.