App.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import 'antd/dist/antd.css'
  2. import './App.scss';
  3. import { Router, Route, Switch, Redirect } from 'react-router-dom';
  4. import createHistory from "history/createBrowserHistory";
  5. import { connect, Provider } from 'react-redux';
  6. import { store } from './redux/redux-store';
  7. import { Authorization } from './pages/Authorization';
  8. import { Content } from './pages/Content';
  9. export const history = createHistory()
  10. const AppContent = ({ isToken }) =>
  11. <Router history={history}>
  12. {!isToken
  13. ?
  14. <Switch>
  15. <Route path='/auth/:_id'
  16. component={Authorization} />
  17. <Redirect from='/*' to='/auth/login' />
  18. </Switch>
  19. :
  20. <Content />
  21. // <Switch>
  22. // <Route path='/' component={Content} exact />
  23. // <Redirect from='/auth/*' to='/' />
  24. // </Switch>
  25. }
  26. </Router >
  27. const CAppContent = connect(state => ({ isToken: state.auth?.token }))(AppContent)
  28. store.subscribe(() => console.log(store.getState()))
  29. function App() {
  30. return (
  31. <Provider store={store}>
  32. <CAppContent />
  33. </Provider>
  34. )
  35. }
  36. export default App;