Changeset 3717 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/index.jsx
- Timestamp:
- 07/24/2016 09:40:56 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/index.jsx
r3701 r3717 1 /* global app_data:object */2 1 import React from 'react'; 3 2 import { render } from 'react-dom'; 4 import { compose, createStore, applyMiddleware } from 'redux'; 5 import { Provider, connect } from 'react-redux'; 6 import thunkMiddleware from 'redux-thunk'; 7 import { Router, useRouterHistory } from 'react-router'; 8 import { syncHistoryWithStore } from 'react-router-redux'; 9 import { createHistory } from 'history'; 10 import throttle from 'lodash/throttle'; 3 import { Provider } from 'react-redux'; 11 4 12 5 /** 13 6 * Internal dependencies. 14 7 */ 15 import reducers from 'reducers'; 16 import routes from 'routes'; 17 import { loadState, saveState } from 'modules/local-storage'; 18 19 // Add the reducer to your store on the `routing` key. 20 const store = compose( 21 applyMiddleware( thunkMiddleware ) 22 )( createStore )( reducers, loadState() ); 23 24 // Save state to local storage when the store gets updated. 25 store.subscribe( throttle( () => { 26 saveState( store.getState() ); 27 }, 1000 ) ); 28 29 const history = useRouterHistory( createHistory )( { 30 basename: app_data.base 31 } ); 8 import Router from 'router'; 9 import getStore from 'store'; 32 10 33 11 render( 34 <Provider store={ store}>35 <Router history={ syncHistoryWithStore( history, store ) } routes={ routes } />12 <Provider store={ getStore() }> 13 { Router } 36 14 </Provider>, 37 15 document.getElementById( 'content' )
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)