From 28e502fe3690a86db91c88fd54d9d40e1ce3c5a5 Mon Sep 17 00:00:00 2001 From: Evgeny Rodionov Date: Mon, 11 Dec 2017 15:03:39 +0300 Subject: [PATCH] fix: update example using es class fields --- README.md | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e1224b0..8da9b43 100644 --- a/README.md +++ b/README.md @@ -28,26 +28,23 @@ import ReactDOM from 'react-dom'; import Wavesurfer from 'react-wavesurfer'; class MyComponent extends React.Component { - constructor(props) { - super(props); - - this.state = { - playing: false, - pos: 0 - }; - this.handleTogglePlay = this.handleTogglePlay.bind(this); - this.handlePosChange = this.handlePosChange.bind(this); + state = { + playing: false, + pos: 0 } - handleTogglePlay() { - this.setState({ - playing: !this.state.playing - }); + + handleTogglePlay = () => { + this.setState(prevState => ({ + playing: !prevState.playing + })); } - handlePosChange(e) { + + handlePosChange = (e) => { this.setState({ pos: e.originalArgs[0] }); } + render() { return (