我有一个onClick
处理程序绑定到currentAreas
组件。当currentAreas
组件被调用时,同时调用onClick
处理程序,但在此之后不起作用。反应OnClick函数不绑定
onClick
当我尝试点击锚标签时不起作用,我认为这可能是由于我绑定onClick
函数的方式。
currentAreas.js
import React, { Component, PropTypes } from 'react';
export default class currentAreas extends Component {
constructor(props) {
super(props);
}
render() {
const { onClick } = this.props;
return(
<div className="list-group panel">
<a href="#demo3" className="list-group-item" onClick={onClick("All", "All")} >All</a>
</div>
);
}
}
currentList.js(主要成分)
class currentList extends Component {
constructor(props) {
super(props);
this.updateLocation = this.updateLocation.bind(this);
}
updateLocation(name, nameLocation){
console.log(name);
console.log(nameLocation);
}
render() {
return (
<div className="step-3-container">
<CurrentAreas
onClick ={this.updateLocation} />
</div>
)
}
}