|
1 | | -// auto create app container if missing |
2 | | -let appContainer = document.getElementById('app-container'); |
3 | | -if (appContainer == null) { |
4 | | - appContainer = document.createElement('div'); |
5 | | - appContainer.id = 'app-container'; |
6 | | - document.body.appendChild(appContainer); |
7 | | -} |
8 | 1 | // lib imports |
9 | 2 | import * as React from 'react'; |
10 | 3 | import * as ReactDOM from 'react-dom'; |
11 | | -// components imports |
12 | | -import { Main } from './components/main'; |
13 | | -import { AppStore, UserData } from './stores/app-store'; |
| 4 | +import { Provider } from 'react-redux'; |
| 5 | +import { Router, Route, hashHistory } from 'react-router'; |
| 6 | +import { syncHistoryWithStore } from 'react-router-redux'; |
| 7 | +// app imports |
| 8 | +import { MainLayout } from './layouts/main-layout'; |
| 9 | +import { HomeContainer } from './containers/home-container/index'; |
| 10 | +import { AboutContainer } from './containers/about-container/index'; |
| 11 | +import CurrencyConverterContainer from './containers/currency-converter-container/index'; |
14 | 12 |
|
15 | | -const message = 'React / Redux / TypeScript - starter-kit'; |
16 | | -const appStore = new AppStore(new UserData('Piotr', 32)); |
17 | | -export var app: any = ReactDOM.render(<Main welcomeMessage={message} appStore={appStore} />, appContainer); |
| 13 | +import { store } from './store'; |
| 14 | +const history = syncHistoryWithStore(hashHistory, store) as any; |
18 | 15 |
|
19 | | -// here you can customize hot-module-reload hook |
20 | | -// you could also copy to other modules |
21 | | -export function __reload(prev) { |
22 | | - if (prev.app.state) |
23 | | - app.setState(prev.app.state); |
| 16 | +function App() { |
| 17 | + return ( |
| 18 | + <Provider store={store}> |
| 19 | + <Router history={history}> |
| 20 | + <Route component={MainLayout}> |
| 21 | + <Route path="/" component={HomeContainer}/> |
| 22 | + <Route path="/about" component={AboutContainer}/> |
| 23 | + <Route path="/currency-converter" component={CurrencyConverterContainer}/> |
| 24 | + </Route> |
| 25 | + </Router> |
| 26 | + </Provider> |
| 27 | + ); |
24 | 28 | } |
| 29 | + |
| 30 | +export const app = ReactDOM.render( |
| 31 | + <App />, document.getElementById('app-container') |
| 32 | +); |
0 commit comments