6

Transferring Properties

Working with properties has a frustrating side. We saw a bit of this side in the previous chapter. Passing properties from one component to another is nice and simple when you’re dealing with only one layer of components. When you want to send a property across multiple layers of components, things start to get complicated.

Complication is never a good thing, so in this chapter, let’s see what we can do to make working with properties easy across multiple layers of components.

Problem Overview

Let’s say that you have a deeply nested component, and its hierarchy (modeled as awesomely colored circles) looks like Figure 6.1.

Figure 6.1 The component hierarchy.

You want to pass a property from your red circle all ...

Get Learning React: A Hands-On Guide to Building Web Applications Using React and Redux, Second edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.