javascript - React. Children as prop - Stack Overflow

I know how to pass children to React ponent:<Button blockhref={url}target="_blank"bsStyle=

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 them this.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
Add a ment  | 

1 Answer 1

Reset to default 6

Yes, 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745161827a4614423.html

相关推荐

  • javascript - React. Children as prop - Stack Overflow

    I know how to pass children to React ponent:<Button blockhref={url}target="_blank"bsStyle=

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信