React Transferring Props除了一个 [英] React Transferring Props except one
本文介绍了React Transferring Props除了一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
React建议转移道具。整洁!
React suggests to Transfer Props. Neat!
我怎样才能转移除一个以外的所有东西?
How can I transfert all but one?
render: function(){
return (<Cpnt {...this.propsButOne}><Subcpnt one={this.props.one} /></Cpnt>);
}
推荐答案
您可以使用以下技巧消耗一些道具并传递其余的道具:
You can use the following technique to consume some of the props and pass on the rest:
render() {
var {one, ...other} = this.props;
return (
<Cpnt {...other}>
<Subcpnt one={one} />
</Cpnt>
);
}
这篇关于React Transferring Props除了一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文