I know how to pass children to React ponent:
<Button block
href={url}
target="_blank"
bsStyle="primary"
bsSize="xsmall">Open This Wonderful Link</Button>
But can I use this way:
<Button block
href={url}
target="_blank"
bsStyle="primary"
bsSize="xsmall"
children="Open This Wonderful Link" />
It works, but is this normal? Can I use this way every time?
P.S. Sorry for my poor English..)
I know how to pass children to React ponent:
<Button block
href={url}
target="_blank"
bsStyle="primary"
bsSize="xsmall">Open This Wonderful Link</Button>
But can I use this way:
<Button block
href={url}
target="_blank"
bsStyle="primary"
bsSize="xsmall"
children="Open This Wonderful Link" />
It works, but is this normal? Can I use this way every time?
P.S. Sorry for my poor English..)
Share Improve this question asked Apr 28, 2017 at 12:03 Виталий ЗаславскийВиталий Заславский 2492 silver badges11 bronze badges 4- You wont to pass react elem to ponent in some props, or you wont to use exactly "children" prop? – Sergey Orlov Commented Apr 28, 2017 at 12:08
- I want to pass children as property in JSX element. In some cases it is more convenient. @SergeyOrlov, are you Russian? – Виталий Заславский Commented Apr 28, 2017 at 12:11
-
You can pass children as props. But you also can pass ponent as other props
someName= {ponents}
and then use themthis.props.someName
. – Sergey Orlov Commented Apr 28, 2017 at 12:19 - Yes this is not only normal but expected. – InfiniteStack Commented Apr 28, 2017 at 13:04
1 Answer
Reset to default 6Yes, children
is like any other prop
and can be used as a prop
to render child ponents, instead of nesting child ponents in the respective element