I am trying to integrate this react swipe module on github. Everything has been going well until I began integrating refs into my code. I am trying to call a react function from an onClick
. Here is the code snippet I am working with:
class Page extends Component {
next() {
this.refs.reactSwipe.next();
}
prev() {
this.refs.reactSwipe.prev();
}
render() {
return (
<div className="center">
<h1>ReactSwipe.js</h1>
<h2>Open this page from a mobile device (real or emulated).</h2>
<h2>You can pass <a href="https://github.com/voronianski/swipe-js-iso#config-options">Swipe.js options</a> as query params.</h2>
<ReactSwipe ref="reactSwipe" className="mySwipe" swipeOptions={swipeOptions}>
{paneNodes}
</ReactSwipe>
<div>
<button type="button" onClick={::this.prev}>Prev</button>
<button type="button" onClick={::this.next}>Next</button>
</div>
</div>
);
}
}
The problem is that web pack is throwing a Module build failed: SyntaxError: Unexpected token
on the :
from the line:
<button type="button" onClick={::this.prev}>Prev</button>
What setting do I need to add to the webpack settings to allow for this ::
?
Or how can I go about calling a react function from the html onClick
without the ::
function binding?