Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. module.exports = function(){
  2. return {
  3.  
  4. getInitialState: function () {
  5. return {
  6. routeComponent: null
  7. };
  8. },
  9.  
  10. runRoute: function(component){
  11. this.setState({routeComponent: component});
  12. this.forceUpdate();
  13. },
  14.  
  15. componentWillMount: function() {
  16. var self = this;
  17. self.router = Router(self.routes).configure({
  18. resource: self,
  19. notFound: self.notFound
  20. });
  21. self.router.init();
  22. }
  23. };
  24. }
  25.  
  26. module.exports = function(React, Router, NotFound, Profile, Board) {
  27. return React.createClass({
  28.  
  29. mixins: [Router],
  30.  
  31. routes: {
  32. '/board': 'trending',
  33. '/board/mostloved': 'mostLoved',
  34. '/profile': 'profile'
  35. },
  36.  
  37. trending: function() {
  38. this.runRoute(
  39. <Board title="Trending Boards" setTitle={this.props.setTitle} />
  40. );
  41. },
  42.  
  43. mostLoved: function() {
  44. this.runRoute(
  45. <Board title="Loved Boards" setTitle={this.props.setTitle} />
  46. );
  47. },
  48.  
  49. profile: function() {
  50. this.runRoute(
  51. <Profile setTitle={this.props.setTitle} />
  52. );
  53. },
  54.  
  55. notFound: function () {
  56. this.runRoute(
  57. <NotFound setTitle={this.props.setTitle} />
  58. );
  59. },
  60.  
  61. render: function() {
  62. return this.state.routeComponent;
  63. }
  64.  
  65. });
  66. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement