Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Stream Props to Multiple Children with React's and RxJS

    John LindquistJohn Lindquist

    Mapping the props to multiple children involves the use of React’s so that you can map over each child Component provided to the Parent Component stream. Inside the mapping function, you use the cloneElement and pass the props manually as you would with a single child component.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: When you declare a second counter and hit save, you'll see everything breaks, because the way we currently have it set up, there's a contract of only one element. To support multiple elements, we come into here and say, "Give me the children, static helper as well," and then we can use that.

    We'll return, and loop through all the props.children. Then use a function which takes the child, and then clones each of those childs, or children, in the same way we did before. Now, you see we have multiple counters here and multiple counters down here.

    As long as this contract holds between a component that takes the value on ink and on deck. Then we can create whatever component we want. We'll call this weird counter, and this can be a span, this can be a span, this can be an h1.

    Then we'll drop a weird counter in here, weird counter. Now, we have a counter component that looks completely different, but it takes the same props. It works just the same as the other.