React Lesson - Compositon with HOCs, Render Props, Hooks and Context

Опубликовано: 08 Октябрь 2024
на канале: Henry Blevins
894
33

Code is here: https://github.com/Blevs/react-compose



It is easy to share logic between React components, as long as it doesn't involve state. Stateful logic is tied deeply to the component itself. This is a problem for logic that we wish to share between many components. Our example today will be a toggle.


Here, we examine four different patterns to compose and share stateful logic between components: Higher Order Components (HOCs), Render Props, Hooks and Context.



Desktop Background 'Our Night Under the Stars' © Trey Ratcliff, Stuck in Customs https://stuckincustoms.com/2010/07/06...