App.js 973 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import './App.scss';
  2. import React from 'react';
  3. import 'bootstrap/dist/css/bootstrap.min.css';
  4. import {Router} from 'react-router-dom';
  5. import createHistory from "history/createBrowserHistory";
  6. import {Provider, connect} from 'react-redux';
  7. import { store } from './store/store';
  8. import { actionAllPlaylists, actionUsersPlaylists } from './store/promiseReducer';
  9. import { Main } from './components/Routs';
  10. export let history = createHistory();
  11. store.subscribe(() => console.log(store.getState()));
  12. store.getState().auth.token && store.dispatch(actionAllPlaylists());
  13. store.getState().auth.token && store.dispatch(actionUsersPlaylists(store.getState().auth?.user?.id));
  14. const CRoutes = connect(state => ({auth : state.auth?.token}))(Main)
  15. function App() {
  16. return (
  17. <div className='d-flex text-white'>
  18. <Router history={history}>
  19. <Provider store ={store}>
  20. <CRoutes/>
  21. </Provider>
  22. </Router>
  23. </div>
  24. );
  25. }
  26. export default App;