Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import React from 'react';
  2. import { Provider, connect } from 'react-redux'
  3. import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
  4. import { Navbar, Nav } from 'react-bootstrap'
  5. import App from './App'
  6. import MyShows from './components/myShows'
  7. import {fetchShow, fetchShows} from './actions/showActions'
  8. //both are imported exact same way, and exported the exact same way.
  9. //Even if it's defined here instead of imported, the same result happens, so it's not a matter of where it resides.
  10. import 'bootstrap/dist/css/bootstrap.css';
  11. import './App.css'
  12.  
  13. const Root = ({ store, shows, addShow, deleteShow, fetchShow }) => (
  14. <Provider store={store}>
  15. <Router>
  16. <Navbar bg="dark" variant="dark" sticky="top">
  17. <Nav className="mr-auto">
  18. <Link className="topLink" to="/">Home</Link>
  19. <Link className="topLink" to="/shows">My Shows</Link>
  20. <Link className="topLink" to="/reviews">Reviews</Link>
  21. </Nav>
  22. </Navbar>
  23. <Route exact path="/" render={() => <App />}/>
  24. <Route path="/shows" render={() => <MyShows shows={shows} addShow={addShow} deleteShow={deleteShow} fetchShow={fetchShow} fetchShows={fetchShows} />} />
  25. </Router>
  26. </Provider>
  27. )
  28.  
  29. const mapStateToProps = (state, ownProps) => {
  30. return {shows: state.shows}
  31. }
  32.  
  33. const mapDispatchToProps = dispatch => ({
  34. addShow: name => dispatch({ type: "ADD_SHOW", name }),
  35. deleteShow: id => dispatch({ type: "DELETE_SHOW", id}),
  36. fetchShow: showDate => dispatch(fetchShow(showDate)),
  37. fetchShows: userId => dispatch(fetchShows(userId))
  38. })
  39.  
  40. export default connect(mapStateToProps, mapDispatchToProps)(Root)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement