I am making a grid, 3 columns each, each a Jumbotron with a button.
renderProperties = data => {
var properties = []
var propRow = []
data.forEach(function(property,index){
propRow.push(<Col xs={{ size:3, offset: .5}}>
<Jumbotron>
<Image src={require("./images/1.jpg")} fluid rounded />
<b> {property.location} </b>
<div>
<td> <Button variant="info" onClick={()=> this.handleRentProperty(property)}> Rent Property </Button> </td>
</div>
</Jumbotron>
</Col> )
if((index+1)%3 == 0){ // if first in the row
properties.push(<Row>{ propRow }</Row>)
propRow = []
}
})
return (
<Container>
{properties}
</Container>
)
}
handleRentProperty = prop =>{
this.setState({show: true});
//this.setState({rentProperty: prop.location })
}
The renderProperties in rendered in the render as :
render() {
{this.renderProperties(data)}
}
I keep on getting
"TypeError: Cannot read property 'handleRentProperty' of undefined"
I have tried bind like in the following different ways:
onClick={(e)=> this.handleRentProperty(property, e)}
onClick={this.handleRentProperty.bind(this, property)}
onClick={this.handleRentProperty(property)}
onClick={()=>this.handleRentProperty.bind(this,property)}