I am trying to pass data from chid to parent but I've been thrown below exception this.props.filterUser is not a function
I am referencing: ReactJS with ES6: this.props is not a function when I communicate two components
Uncaught TypeError: this.props.filterUser is not a function
class Mobile extends React.Component {
constructor() {
super();
this.legendBtnHandler = this.legendBtnHandler.bind(this);
this.state = {
mobileExtentions: '',
legendInfo: '',
buttonName: 'test'
}
};
componentWillMount(){
const listItems = mobileExt.map((ext) =>
<p>
<RaisedButton label={ext.name} secondary={true} id="mobileBtn" onClick={() => this.legendBtnHandler(ext.name)}/>
</p>
);
this.setState({mobileExtentions: listItems});
};
legendBtnHandler(btnName){
this.setState({buttonName: btnName});
Store.buttonName = btnName;
this.props.filterUser("test");
};
render(){
const dragHandlers = {onStart: this.onStart, onStop: this.onStop};
return(
<div>
<DraggableCard
mobileExtentions = { this.state.mobileExtentions }
legendInfo = { mobileExt[0].legendInfo }
/>
</div>
)
}
};
Parent
class MapClass extends React.Component {
constructor(props) {
super(props);
this.filterUser = this.filterUser.bind(this);
this.state = {
filter: ''
//btnName: Legend.props.test
}
}
filterUser(filterValue){
alert(filterValue)
this.setState({
filter: filterValue
});
}
render(){
return(
<Mobile filterUser={this.filterUser}/>
)
}
}