Reputation: 163
Im trying to get the props passed to my parent component using this.state.props in my child component.
I have googled everywhere
choice(){
console.log(this.props.size);
}
{this.props.size && <DropdownItem onClick={this.choice} className="bg-info">{this.props.size}</DropdownItem>}
this is the parent component
<DropDown
title="Options"
special={special}
size={size1}
Upvotes: 1
Views: 36
Reputation: 1643
Try this:
choice() {
console.log(this.props.size);
}
{this.props.size && <DropdownItem onClick={() => this.choice()} className="bg-info">{this.props.size}</DropdownItem>}
If you want to change the size each time you click it, you have to use state
and not props
.
Upvotes: 1