Im新手到React js,我不知道下面的代码有什么问题,但我得到setState不是函数错误。请帮我解决这个问题。Reactjs this.setState不是函数错误
class AppBarLayout extends React.Component {
constructor(props) {
super(props);
this.state = {
visibleSideBar:true,
slide:""
}
}
showProfile(){
this.setState({
slide:'slide'
});
console.log(this.state.slide);
}
render(){
return(
<div>
<header>
<NavBar show={this.showProfile}/>
<Profile slide={this.state.slide} />
</header>
</div>
);
}
}
export default AppBarLayout;
的可能的复制[无法访问阵营实例(本)事件处理程序内(http://stackoverflow.com/questions/29577977/unable-to-access-react- instance-this-inside-event-handler) –