W
W
webe2019-01-18 14:22:30
React
webe, 2019-01-18 14:22:30

How to get access to the child's props?

I found a way out, but it seems to me a bad approach.
Are there others please tell me?
I pass small components to my component, and I pass props to these small ones.

import {Title, Container} from 'SDSlider'
<Component>
<Title caption="Маша">16</Title>
<Title caption="Коля">22</Title>
</Container>

Inside the container I render via React.Children.map(child=>....) and get the person's name via child.props.title
is this legal?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-01-18
@webe

Yes, it's legal, other options will be crutch and nasty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question