Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <Router history={browserHistory}>
  2. <Route component={Loader}>
  3. <Route path="/" component={MainLayout}>
  4. <IndexRoute components={{ rightSidebar: RightSidebar, main: Dashboard }} />
  5. <Route path="accounts" components={{ rightSidebar: RightSidebar, main: Accounts }} />
  6. </Route>
  7. </Route>
  8. <Route path="*" component={PageNotFound} />
  9.  
  10. import React from 'react';
  11. import { connect } from 'react-redux';
  12.  
  13. import { fetchUsersInfo } from 'actions/index.actions';
  14. import Spinner from 'components/spinner/Spinner.component';
  15. class Loader extends React.Component {
  16. componentDidMount() {
  17. this.props.fetchUsersInfo();
  18. }
  19.  
  20. render() {
  21. return (
  22. <div>
  23. {this.props.appState.isFetchingUsersInfo ?
  24. <div>
  25. <Spinner />
  26. </div>
  27. :
  28. <div>
  29. {this.props.children}
  30. </div>
  31. }
  32. </div>
  33. );
  34. }
  35. }
  36.  
  37. Loader.propTypes = {
  38. children: React.PropTypes.node.isRequired,
  39. appState: React.PropTypes.shape({
  40. isFetchingUsersInfo: React.PropTypes.bool.isRequired,
  41. }),
  42. fetchUsersInfo: React.PropTypes.func.isRequired,
  43. };
  44.  
  45. const mapStateToProps = state => ({
  46. appState: {
  47. isFetchingUsersInfo: state.appState.isFetchingUsersInfo,
  48. },
  49. });
  50.  
  51. export default connect(mapStateToProps, { fetchUsersInfo })(Loader);
  52.  
  53. import React from 'react';
  54. import { connect } from 'react-redux';
  55.  
  56. import { fetchAllProjects } from 'actions/index.actions';
  57.  
  58. import styles from './Dashboard.container.scss';
  59.  
  60. class Dashboard extends React.Component {
  61. componentDidMount() {
  62. this.props.fetchAllProjects();
  63. }
  64. render() {
  65. return (
  66. <div>
  67. Dashboard
  68. </div>
  69. );
  70. }
  71. }
  72.  
  73. Dashboard.propTypes = {
  74. appState: React.PropTypes.shape({
  75. isFetchingProjects: React.PropTypes.bool.isRequired,
  76. }),
  77. fetchAllProjects: React.PropTypes.func.isRequired,
  78. };
  79.  
  80. const mapStateToProps = state => ({
  81. appState: {
  82. isFetchingProjects: state.appState.isFetchingProjects,
  83. },
  84. });
  85.  
  86. export default connect(mapStateToProps, { fetchAllProjects })(Dashboard);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement