Im working with a react.js app, and I remember that I was able to pass a callback function from a child to a parent with pops, the thing is I cant achieve to do this again (I'd like to keep it simple, without Flux libraries):
So my parent App
:
class App extends Component {
constructor(props) {
super(props);
}
showViewAction(viewToShow){
console.log(viewToShow);
}
render() {
return (
<div>
<AppMenu showView={this.showViewAction}/>
</div>
);
}
}
And my child AppMenu
:
class AppMenu extends Component{
constructor(props) {
super(props);
}
showCirculares(){
this.props.showView("circulares");
}
render(){
return(
<div>
<MenuButton onClick={this.showCirculares} buttonTitle="SomeOtherProp"/>
</div>
);
}
}
Everything I try, I always get:
Cannot read property 'props' of undefined at showCirculares;
I know this will be resolved with a simple task, and that this is basic React.js stuff, its just that I cant find a solution for this!! What am I doing wrong?