Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PlayerControls extends React.Component {
- constructor(props) {
- super(props)
- this.state = {
- loopActive: false,
- shuffleActive: false,
- }
- }
- render() {
- var shuffleClassName = this.state.toggleActive ? "player-control-icon active" : "player-control-icon"
- return (
- <div className="player-controls">
- <FontAwesome
- className="player-control-icon"
- name='refresh'
- onClick={this.onToggleLoop}
- spin={this.state.loopActive}
- />
- <FontAwesome
- className={shuffleClassName}
- name='random'
- onClick={this.onToggleShuffle}
- />
- </div>
- );
- }
- onToggleLoop(event) {
- // "this is undefined??" <--- here
- this.setState({loopActive: !this.state.loopActive})
- this.props.onToggleLoop()
- }
- constructor (props){
- super(props);
- this.state = {
- loopActive: false,
- shuffleActive: false,
- };
- this.onToggleLoop = this.onToggleLoop.bind(this);
- }
- onToggleLoop = (event) => {
- this.setState({loopActive: !this.state.loopActive})
- this.props.onToggleLoop()
- }
- {someList.map(function(listItem) {
- // your code
- }, this)}
- {someList.map((listItem, index) =>
- <div onClick={this.someFunction.bind(this, listItem)} />
- )}
Add Comment
Please, Sign In to add comment