Brian Jenney
Aug 28, 2023

--

Great question.

You're correct that the goal is to be loosely coupled, and the static properties support this. They define a kind of 'contract' without imposing rigid constraints. Let's say you decide to swap out Cart.Item for another component, you can do so without affecting the Cart container or needing to change how the context is accessed.

I think this can prevent swiss-army knife components where you need a component to render differently depending on the context while still enforcing some standards and structure. The shopping cart is a component that lends itself to this pattern well or some other structured UI like an article where you will likely have some common elements that you want to compose in 1 of n ways.

Hope that sheds some light on my thought process.

--

--

Brian Jenney
Brian Jenney

Written by Brian Jenney

full-stackish developer, late bloomer coder and power google user and owner of Parsity.io

No responses yet