Posts

Showing posts from May, 2019

React Prop drilling - Kent Dodds

A way of sharing state by passing state properties through components (which may not use the data themselves) to child components that need it. Kents article Prop drilling is appropriate in some circumstances and is explicit (which makes it easier to debug). Lifting state up to the closest common component and then passing it down to child components is a pattern that works for many cases and we use all the time.  But Prop drilling can come with problems if the shape/name of data properties change or child components change and no longer need the data We've seen this happens quite often as apps scale up in size: "hmmm what children components use those props? I dunno" or "why is this child component broken?" Kent says one way to avoid this is don't break out render into multiple components unnecessarily. Wait until you need to reuse.  Now this is interesting to me. Many times we break up components into separate components for reasons other than just reuse