Guest User

Untitled

a guest
Jan 4th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import './index.css';
  4. import App from './components/App';
  5. import registerServiceWorker from './registerServiceWorker';
  6. import { render } from 'react-dom'
  7. import { createStore, combineReducers, applyMiddleware } from 'redux'
  8. import { Provider } from 'react-redux'
  9. import configureStore from './store/configureStore'
  10. import { Route } from 'react-router-dom'
  11. //import routes from './routes'
  12.  
  13. import { ConnectedRouter as Router, routerMiddleware, push } from 'react-router-redux'
  14. import createHistory from 'history/createBrowserHistory'
  15.  
  16. const history = createHistory();
  17. const middleware = routerMiddleware(history);
  18. const store = configureStore(middleware);
  19.  
  20. ReactDOM.render(
  21. <Provider store={store}>
  22.  
  23. <Router history={history} >
  24. <Route path="/" component={App}/>
  25. </Router>
  26. </Provider>, document.getElementById('root'));
  27. registerServiceWorker();
  28. store.subscribe(() => {
  29. console.log('Store has changed')
  30. })
  31.  
  32. import { createStore, applyMiddleware, combineReducers } from 'redux'
  33. import rootReducer from '../reducers'
  34. import { composeWithDevTools } from 'redux-devtools-extension'
  35. import thunk from 'redux-thunk'
  36. import promise from 'redux-promise-middleware'
  37. import { routerReducer } from 'react-router-redux'
  38.  
  39.  
  40. export default function configureStore(middleware) {
  41. const reducers = combineReducers({ rootReducer, router: routerReducer })
  42. const store = createStore(reducers, composeWithDevTools(applyMiddleware(thunk,promise(), middleware )))
  43.  
  44. if (module.hot) {
  45. module.hot.accept('../reducers', () => {
  46. const nextRootReducer = require('../reducers')
  47. store.replaceReducer(nextRootReducer)
  48. })
  49. }
  50.  
  51. return store
  52. }
  53.  
  54. import React from 'react';
  55. import PropTypes from 'prop-types';
  56. import classNames from 'classnames';
  57. import { withStyles } from 'material-ui/styles';
  58. import Drawer from 'material-ui/Drawer';
  59. import AppBar from 'material-ui/AppBar';
  60. import Toolbar from 'material-ui/Toolbar';
  61.  
  62.  
  63. import SidebarContainer from './aside/SidebarContainer'
  64.  
  65. const drawerWidth = 240; //Sidebar have it too
  66. const styles = theme => ...;
  67.  
  68. class App extends React.Component {
  69.  
  70. render() {
  71. const { classes } = this.props;
  72.  
  73. return (
  74. <div className={classes.root}>
  75.  
  76. <div className={classes.appFrame}>
  77. <AppBar className={classNames(classes.appBar, classes[`appBar-left`])}>
  78. <Toolbar>
  79.  
  80. </Toolbar>
  81. </AppBar>
  82. <SidebarContainer/> //ошибка здесь
  83. <main className={classes.content}>
  84.  
  85. </main>
  86. </div>
  87. </div>
  88. );
  89. }
  90. }
  91.  
  92. App.propTypes = {
  93. classes: PropTypes.object.isRequired,
  94. };
  95.  
  96. export default withStyles(styles)(App);
  97.  
  98. import React, { Component } from 'react'
  99.  
  100. import { connect } from 'react-redux';
  101. import {bindActionCreators} from 'redux';
  102. import Sidebar from './Sidebar'
  103. import {addList,fetchLists,setCurrentList} from '../../actions/'
  104.  
  105. class SidebarContainer extends Component {
  106. constructor(props){
  107. super(props);
  108. this.state = {
  109.  
  110. }
  111. }
  112. addList(list){
  113. this.props.onAddList(list)
  114. }
  115. componentWillMount(){
  116. this.props.onFetchLists()
  117. }
  118. render(){
  119. console.log(this.props.lists)
  120. return (
  121.  
  122. <Sidebar lists={this.props.lists} onBtnAddClick={this.addList.bind(this)}/>
  123.  
  124. )
  125. }
  126. }
  127.  
  128. function mapStateToProps(state){
  129. return {
  130. lists: state.lists,
  131. currentList: state.currentList
  132. }
  133. }
  134. function mapDispatchToProps(dispatch){
  135. return {
  136. onAddList: (newList) => {
  137. dispatch(addList(newList))
  138. },
  139. onFetchLists: () => {
  140. dispatch(fetchLists())
  141. }
  142. }
  143. }
  144.  
  145. export default connect(mapStateToProps,mapDispatchToProps)(SidebarContainer);
Add Comment
Please, Sign In to add comment