๐ฏ UPDATED: Advanced React Component Patternsย โ๏ธ
Now featuring the latest React APIs (like context) and entirely new patterns (like state reducer props).
TL;DR
My highly popular course has been updated (completely re-recorded) and you can find it here:
๐๐๐๐๐๐๐๐๐
๐๐๐๐๐๐๐๐๐
Hereโs the intro: youtu.be/za3Ddz7woNw
ALSO! You can follow along in codesandbox.
So whatโs new?
This course was originally published in December 2017. A few months after it was published, React 16.3.0 was released with some new APIs that really improved the usability of React for some of these patterns.
Compound Components + Context API = โค๏ธ
In particular, the Context API makes compound components much easier to make more flexible:
Make Compound React Components Flexible
I also have a few extra lessons to show you how you can validate that your Context Consumers are used properly:
Validate Compound Component Context Consumers
And hereโs another that shows you how to properly use the Context Provider to avoid unnecessary re-renders of your consumers:
Prevent Unnecessary Rerenders of Compound Components using React Context
Render Props
The render prop lessons have also been re-recorded, though no new React APIs were needed to make it remain an awesome pattern ๐ People have told me that they really appreciate the way I teach render props:
We also still have the prop collections and prop getters patterns because those are still very awesome.
State Reducers
We have a few lessons that feature a completely new pattern that wasnโt in the original course that I implemented a while ago in downshift called the state reducer pattern:
Implement Component State Reducers
Improve the usability of Component State Reducers with state change types
Control Props
In the last course we had control props, but Iโve taken it further in this update to have more lessons about this subject and simplified the examples while making the implementation more real-world as well so you can focus on learning how to effectively use the pattern:
Make Controlled React Components with Control Props
Support Control Props for all state
Support a state change handler for all control props
Improve the usability of Control Props with state change types
The Provider Pattern
Last time, we had quite a few lessons about the provider pattern. With the new Context API, I was able to show everything in a single lesson because the Context API is a built-in implementation of the provider pattern! In this lesson I give a demonstration of what Prop Drilling is and how the Provider Pattern can simplify things considerably making your React codebase much more manageable.
Implement the Provider Pattern with React Context
Higher Order Components
React 16.3.0 published a new API called React.forwardRef that simplified creating Higher Order Components (HOCs) in a big way. In this lesson youโll learn how to use that effectively. While everyone out there is all hyped up on render props (yourโs truly included), higher components do still have a place and value in the discussion of react patterns. This lesson is built on top of the provider pattern lesson so you can see how to turn a Context Consumer into a Higher Order Component.
Implement a Higher Order Component
Now go watch it!
Thanks so much for all the support with all this content. This time around itโs 20 minutes shorter than last time (despite having a few extra lessons for an entirely new pattern) because React keeps getting better at enabling these patterns. I hope you love it!
๐๐๐๐๐๐๐๐๐
๐๐๐๐๐๐๐๐๐
Please share this blog post and the course link with your friends!
๐ Hi! Iโm Kent C. Dodds. I work at PayPal as a full stack JavaScript engineer. I represent PayPal on the TC39. Iโm actively involved in the open source community. Iโm an instructor on egghead.io, Frontend Masters, and Workshop.me. Iโm also a Google Developer Expert. Iโm happily married and the father of four kids. I like my family, code, JavaScript, and React.