Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. class PlayerControls extends React.Component {
  2. constructor(props) {
  3. super(props)
  4.  
  5. this.state = {
  6. loopActive: false,
  7. shuffleActive: false,
  8. }
  9. }
  10.  
  11. render() {
  12. var shuffleClassName = this.state.toggleActive ? "player-control-icon active" : "player-control-icon"
  13.  
  14. return (
  15. <div className="player-controls">
  16. <FontAwesome
  17. className="player-control-icon"
  18. name='refresh'
  19. onClick={this.onToggleLoop}
  20. spin={this.state.loopActive}
  21. />
  22. <FontAwesome
  23. className={shuffleClassName}
  24. name='random'
  25. onClick={this.onToggleShuffle}
  26. />
  27. </div>
  28. );
  29. }
  30.  
  31. onToggleLoop(event) {
  32. // "this is undefined??" <--- here
  33. this.setState({loopActive: !this.state.loopActive})
  34. this.props.onToggleLoop()
  35. }
  36.  
  37. constructor (props){
  38. super(props);
  39.  
  40. this.state = {
  41. loopActive: false,
  42. shuffleActive: false,
  43. };
  44.  
  45. this.onToggleLoop = this.onToggleLoop.bind(this);
  46.  
  47. }
  48.  
  49. onToggleLoop = (event) => {
  50. this.setState({loopActive: !this.state.loopActive})
  51. this.props.onToggleLoop()
  52. }
  53.  
  54. {someList.map(function(listItem) {
  55. // your code
  56. }, this)}
  57.  
  58. {someList.map((listItem, index) =>
  59. <div onClick={this.someFunction.bind(this, listItem)} />
  60. )}
Add Comment
Please, Sign In to add comment