Hi @JesperWe
If you use classes the functions are not bind. There are a couple of options on what you can do, the first option binding the function to the class in the constructor. This is necessary for classes:
export class Result extends Component {
constructor(props) {
super(props);
this. handleClick = this. handleClick.bind(this);
}
handleClick() {
ons.notification.alert( this.props.result._id );
}
render() {
return ( <Col onClick={this.handleClick}>{this.props.result.text}</Col> );
}
}
The second option is to use React.createClass, this bind it automatically:
const Result = React.createClass({
handleClick: function() {
ons.notification.alert( this.props.result._id );
},
render: function() {
return (
<Col
onClick={this.handleClick}
>{this.props.result.text}
</Col>
);
}
}
export Result