const {document} = this.props和({document} = this.props)有什么区别

时间:2016-08-24 14:20:43

标签: reactjs

const {document} = this.props({document} = this.props)之间有什么区别?我在很多情况下使用const {document} = this.props,我想知道它在应用程序性能上是否会有差异?

1 个答案:

答案 0 :(得分:1)

/* document key from this.props is stored in const document
   & it called destructing object ( introduced in es6 ) */

   const {document} = this.props;

而({document} = this.props)返回带有可变的密钥文档的对象。意味着如果您稍后更改文档值,它也会反映在this.props中(不推荐)。

相关问题