How to traverse one element to another?

There is a slider with pictures, and I want to traverse not img (which you can't do by default), and, for example, the card with the goods and such other props. But I don't understand how it's like to traverse through the props. As it can be easier to solve. https://codesandbox.io/s/ly8vp183p9
March 19th 20 at 09:02
2 answers
March 19th 20 at 09:04
Solution
const ItemComponent = props => (
the <div>
<p>{props.title}</p>
</div>
);

...

<Carousel
items={items}
ItemComponent={ItemComponent}
/>

UPD. https://codesandbox.io/s/42p1q66589
Thank you, but how to do if I need the default tag? I want to do if nothing is passed, I want to make standard for example to put the img? - kay.Sawayn commented on March 19th 20 at 09:07
@kay.Sawayn, well, make a separate component and render'e Carousel when gestructureerde props, substitute it as the default values for ItemComponent. Unable to open the link of answer again, I added an example. - Zoey.Oberbrunner commented on March 19th 20 at 09:10
@Zoey.Oberbrunner, Thank you very much - kay.Sawayn commented on March 19th 20 at 09:13
March 19th 20 at 09:06
Traverse component can
<Carousel>
the <div>
<p>text</p>
</div>
</Carousel>


In the component Carousel, it will be available via props.children
And it is impossible to do so(I know you can, but do not know how ) - kay.Sawayn commented on March 19th 20 at 09:09
@kay.Sawaynso - how?) - carli.O commented on March 19th 20 at 09:12
@carli.O, With reference to what is not so( - kay.Sawayn commented on March 19th 20 at 09:15

Find more questions by tags React