Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/modules/router.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/modules/router.jsx
r4223 r5024 1 /* global add_data:object */ 1 /** 2 * External dependencies. 3 */ 2 4 import React from 'react'; 3 import { connect } from 'react-redux'; 4 import { Router, Route, IndexRoute, useRouterHistory } from 'react-router'; 5 import createBrowserHistory from 'history/lib/createBrowserHistory'; 5 import { Route, IndexRoute } from 'react-router'; 6 import { ReduxRouter } from 'redux-router'; 6 7 8 /** 9 * Internal dependencies. 10 */ 7 11 import ArchiveBrowse from 'components/archive/browse'; 8 12 import FrontPage from 'components/front-page'; … … 15 19 import SiteMain from 'components/site-main'; 16 20 17 const history = useRouterHistory( createBrowserHistory )( { 18 /** @type {object} app_data Description */ 19 basename: app_data.base 20 } ); 21 const onUpdate = () => window.scrollTo( 0, 0 ); 22 23 export const routes = ( 24 <Route name="root" component={ PluginDirectory }> 25 <Route path="/" components={ { header: SiteHeader, main: SiteMain } }> 26 <IndexRoute component={ FrontPage } /> 27 <Route path="browse/favorites/:username" component={ ArchiveBrowse } /> 28 <Route path="browse/:type/page/:page" component={ ArchiveBrowse } /> 29 <Route path="browse/:type" component={ ArchiveBrowse } /> 30 <Route path="developers" component={ Page } /> 31 <Route path="search/:search" component={ Search } /> 32 <Route path=":slug" component={ Plugin } /> 33 <Route path="*" component={ NotFound } /> 34 </Route> 35 </Route> 36 ); 21 37 22 38 export default ( 23 <Router history={ history } onUpdate={ () => window.scrollTo( 0, 0 ) }> 24 <Route name="root" component={ PluginDirectory }> 25 <Route path="/" components={ { header: SiteHeader, main: SiteMain } }> 26 <IndexRoute component={ FrontPage } /> 27 <Route path="browse/favorites/:username" component={ ArchiveBrowse } /> 28 <Route path="browse/:type" component={ ArchiveBrowse } /> 29 <Route path="developers" component={ Page } /> 30 <Route path="search/:searchTerm" component={ Search } /> 31 <Route path=":slug" component={ Plugin } /> 32 <Route path="*" component={ NotFound } /> 33 </Route> 34 </Route> 35 </Router> 39 <ReduxRouter onUpdate={ onUpdate }> 40 { routes } 41 </ReduxRouter> 36 42 );
Note: See TracChangeset
for help on using the changeset viewer.