Created
October 18, 2016 03:31
-
-
Save austinhinderer/6d193a2035ee6d65834084c30a789f81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import CSSModules from 'react-css-modules'; | |
import styles from './ProgressButton.css'; | |
import ProgressBar from '../ProgressBar'; | |
class ProgressButton extends React.Component { | |
constructor(props) { | |
super(props); | |
this. _onClick = this. _onClick.bind(this); | |
this.state = { max: 1, value: 0 } | |
} | |
render() { | |
return ( | |
<button | |
onClick={this._onClick} | |
styleName='root'> | |
{ this.props.value } | |
<ProgressBar value={ this.state.value } max={ this.state.max } /> | |
</button> | |
) | |
} | |
_onClick() { | |
this.setState({ value: 0 }); | |
console.log('At least this works'); | |
console.log(this.state); | |
const interval = setInterval(tween, 10); | |
function tween({ state = this.state }) { | |
console.log('Ziggy!'); | |
if (state.value >= 1) { | |
clearInterval(interval); | |
} else { | |
this.setState({ value: state.value + .01 }); | |
} | |
}.bind(this); | |
} | |
} | |
export default CSSModules(ProgressButton, styles); | |
ProgressButton.propTypes = { | |
value: React.PropTypes.string.isRequired | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment