You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.web.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { browserHistory } from 'react-router';
  4. import {
  5. routerMiddleware,
  6. routerReducer
  7. } from 'react-router-redux';
  8. import { compose, createStore } from 'redux';
  9. import Thunk from 'redux-thunk';
  10. import config from './config';
  11. import { App } from './features/app';
  12. import {
  13. MiddlewareRegistry,
  14. ReducerRegistry
  15. } from './features/base/redux';
  16. // Create combined reducer from all reducers in registry + routerReducer from
  17. // 'react-router-redux' module (stores location updates from history).
  18. // @see https://github.com/reactjs/react-router-redux#routerreducer.
  19. const reducer = ReducerRegistry.combineReducers({
  20. routing: routerReducer
  21. });
  22. // Apply all registered middleware from the MiddlewareRegistry + additional
  23. // 3rd party middleware:
  24. // - Thunk - allows us to dispatch async actions easily. For more info
  25. // @see https://github.com/gaearon/redux-thunk.
  26. // - routerMiddleware - middleware from 'react-router-redux' module to track
  27. // changes in browser history inside Redux state. For more information
  28. // @see https://github.com/reactjs/react-router-redux.
  29. let middleware = MiddlewareRegistry.applyMiddleware(
  30. Thunk,
  31. routerMiddleware(browserHistory));
  32. // Try to enable Redux DevTools Chrome extension in order to make it available
  33. // for the purposes of facilitating development.
  34. let devToolsExtension;
  35. if (typeof window === 'object'
  36. && (devToolsExtension = window.devToolsExtension)) {
  37. middleware = compose(middleware, devToolsExtension());
  38. }
  39. // Create Redux store with our reducer and middleware.
  40. const store = createStore(reducer, middleware);
  41. // Render the main Component.
  42. ReactDOM.render(
  43. <App
  44. config = { config }
  45. store = { store }
  46. url = { window.location.toString() } />,
  47. document.getElementById('react'));