import React from 'react' ; import { Switch , Route } from 'react-router-dom' ; import { usePagePaths } from './state' ; import PageLoader from './PageLoader' ; const App = ( ) => { const pageRoutes = usePagePaths ( ) . filter ( ( path ) => path !== '/404' ) . sort ( ( pathA , pathB ) => { if ( pathA . includes ( '/:' ) ) return 1 ; if ( pathB . includes ( '/:' ) ) return - 1 ; return 0 ; } ) . map ( ( path ) => ( < Route key = "same" exact path = { path } > < PageLoader routePath = { path } / > < /Route>)); return ( < Switch > { pageRoutes } < Route key = "same" path = "*" render = { ( { match } ) => { return < PageLoader routePath = { match . url } />; } } /> < /Switch>); } ; export default App ;