Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. import React from 'react';
  2. import store from '../store/configureStore'
  3. import {Link} from 'react-router'
  4.  
  5. import csgoTwitch from '../json/cs-go-twitch'
  6. import csgoYoutube from '../json/cs-go-youtube'
  7. import dota2twitch from '../json/dota2-twitch'
  8. import dota2youtube from '../json/dota2-youtube'
  9.  
  10. import {fetchTwitch} from '../actions/fetchTwitch';
  11.  
  12. const Menu = [
  13. {
  14. to: '/',
  15. name: 'CS GO',
  16. youtubeJson: csgoYoutube,
  17. twitchJson: csgoTwitch,
  18. twitter: 'Kreiz0/lists/csgo'
  19. },
  20. {
  21. to: '/',
  22. name: 'DOTA2',
  23. youtubeJson: dota2youtube,
  24. twitchJson: dota2twitch,
  25. twitter: 'Kreiz0/lists/dota'
  26. },
  27. {
  28. to: '/Start',
  29. name: 'Start'
  30. }
  31. ];
  32.  
  33.  
  34. export default class App extends React.Component {
  35. constructor(props) {
  36. super(props);
  37. this.handleClick = ::this.handleClick;
  38. this.state = {
  39. activeIndex: []
  40. };
  41. }
  42.  
  43. handleClick(item, selectedIndex) {
  44. this.setState({selectedIndex});
  45. if (item.twitchJson || item.youtubeJson) {
  46. store.dispatch([
  47. {
  48. type: 'LOAD_TWITCH',
  49. twitchGame: fetchTwitch(item.twitchJson),
  50. },
  51. {
  52. type: 'LOAD_YOUTUBE',
  53. youtubeGame: item.youtubeJson
  54. },
  55. {
  56. type: 'LOAD_TWITTER',
  57. twitterGame: item.twitter
  58. },
  59. ]);
  60. }
  61. }
  62. render() {
  63. return (
  64. <div className="container">
  65. <header className="header block-style">
  66. <ul>
  67. {
  68. Menu.map((item, index) => {
  69. return (
  70. <li key={index}>
  71. <Link to={item.to} className={(this.state.selectedIndex === index) && 'active'}
  72. onClick={this.handleClick.bind(this, item, index)}>
  73. {item.name}
  74. </Link>
  75. </li>
  76. );
  77. })
  78. }
  79. </ul>
  80. </header>
  81. {this.props.children}
  82. </div>
  83. )
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement