I need to fire an event on Click
i.e handleClick
. It's not working either on the image or any button.
I tried arrow functions too but that is also of no use. Neither it is throwing any error. Can anyone suggest something?
let Blips = React.createClass({
handleClick(){
if (this.props.user_name != null) {
sessionStorage.setItem('user_name', JSON.stringify(this.props.user_name))
sessionStorage.setItem('port_id', JSON.stringify(this.props.port_id))
sessionStorage.setItem('ship_image', JSON.stringify(this.props.ship_image))
sessionStorage.setItem('port_type', JSON.stringify(this.props.port_type))
browserHistory.push('/dockedship/')
}
},
render(){
if (this.props.user_name) {
return (
<li className="layer" data-depth={this.props.data_depth}>
<div className={this.props.css_location}>
<img className="glyphport" onClick={this.handleClick} src={this.props.port_type_image}/>
<img className="shipport" src={this.props.ship_image}/>
</div>
</li>
)
}
}
})
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…