react中props属性传递的问题,const {dataSource}= this.props;

     const { dataSource } = this.props;

如上面代码,这是什么意思?希望详细说明,为什么不能够用下面的方式取值

     const { dataSource } = this.props.dataSource;

上面这种方式为什么取到的值是undefined

可以了解一下 js的解构赋值

对于这么愚蠢的问题,现在看来真是的,怎么会有这种问题:
这种就是es6中的解构赋值,从this.props中获取dataSource的方式,要么采用结构赋值const {dataSource}= this.props;,要么直接获取值:`




const dataSource = this.props.dataSource;

dataSource这个属性有初始值吗?没有的话就可能是undefined了

const { dataSource } = this.props 相当于 const dataSource = this.props.dataSource;