export default class customer {
}
render(){
const{
handleSubmit,
pristine,
submitting
} = this.props;
return{
<div>
</div>
}
}
my react-redux code has something like this. can any one tell me why we are using const
and this.props
in the code
can any one tell me why we are using "const"
const
is another way to declare a variable. These variables disallow reassignment. const
is generally a safer way to declare variables, depending on the developer's intent.
can any one tell me why we are using this.props in the code
That's an assignment/deconstructing shorthand. The syntax is something like this:
var {
property
} = object;
What you're doing is creating local variables from the properties of the object. That code is identical to:
var property = object.property;
So in your code, you can think of
const {
handleSubmit,
pristine,
submitting
} = this.props;
as simply
const handleSubmit = this.props.handleSubmit;
const pristine = this.props.pristine;
const submitting = this.props.submitting;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With