react-redux 中的 const 和 props 指的是什么?
what does const and props refer to in react-redux?
export default class customer {
}
render(){
const{
handleSubmit,
pristine,
submitting
} = this.props;
return{
<div>
</div>
}
}
我的 react-redux 代码有这样的东西。谁能告诉我为什么我们在代码
中使用 const
和 this.props
can any one tell me why we are using "const"
const
是声明变量的另一种方式。这些变量不允许重新分配。 const
通常是一种更安全的变量声明方式,具体取决于开发人员的意图。
can any one tell me why we are using this.props in the code
那是 assignment/deconstructing shorthand。语法是这样的:
var {
property
} = object;
您所做的是根据对象的属性创建局部变量。该代码等同于:
var property = object.property;
所以在你的代码中,你可以想到
const {
handleSubmit,
pristine,
submitting
} = this.props;
简单
const handleSubmit = this.props.handleSubmit;
const pristine = this.props.pristine;
const submitting = this.props.submitting;
export default class customer {
}
render(){
const{
handleSubmit,
pristine,
submitting
} = this.props;
return{
<div>
</div>
}
}
我的 react-redux 代码有这样的东西。谁能告诉我为什么我们在代码
中使用const
和 this.props
can any one tell me why we are using "const"
const
是声明变量的另一种方式。这些变量不允许重新分配。 const
通常是一种更安全的变量声明方式,具体取决于开发人员的意图。
can any one tell me why we are using this.props in the code
那是 assignment/deconstructing shorthand。语法是这样的:
var {
property
} = object;
您所做的是根据对象的属性创建局部变量。该代码等同于:
var property = object.property;
所以在你的代码中,你可以想到
const {
handleSubmit,
pristine,
submitting
} = this.props;
简单
const handleSubmit = this.props.handleSubmit;
const pristine = this.props.pristine;
const submitting = this.props.submitting;