React.js: Wrapping one component into another

前端 未结 3 823
感动是毒
感动是毒 2020-12-04 05:17

Many template languages have \"slots\" or \"yield\" statements, that allow to do some sort of inversion of control to wrap one template inside of another.

Angular ha

3条回答
  •  执笔经年
    2020-12-04 05:31

    In addition to Sophie's answer, I also have found a use in sending in child component types, doing something like this:

    var ListView = React.createClass({
        render: function() {
            var items = this.props.data.map(function(item) {
                return this.props.delegate({data:item});
            }.bind(this));
            return 
      {items}
    ; } }); var ItemDelegate = React.createClass({ render: function() { return
  • {this.props.data}
  • } }); var Wrapper = React.createClass({ render: function() { return } });

提交回复
热议问题