github.com/MontFerret/ferret@v0.18.0/e2e/pages/dynamic/components/app.js (about)

     1  import Layout from './layout.js';
     2  import IndexPage from './pages/index.js';
     3  import FormsPage from './pages/forms/index.js';
     4  import EventsPage from './pages/events/index.js';
     5  import IframePage from './pages/iframes/index.js';
     6  import MediaPage from './pages/media/index.js';
     7  import PaginationPage from './pages/pagination/index.js';
     8  import ListsPage from './pages/lists/index.js';
     9  import NavigationPage from './pages/navigation/index.js';
    10  
    11  const e = React.createElement;
    12  const Router = ReactRouter.Router;
    13  const Switch = ReactRouter.Switch;
    14  const Route = ReactRouter.Route;
    15  const Redirect = ReactRouter.Redirect;
    16  const createHistory = History.createHashHistory;
    17  
    18  export default React.memo(function AppComponent(params = {}) {
    19      let redirectTo;
    20  
    21      if (params.redirect) {
    22          let search = '';
    23  
    24          Object.keys(params).forEach((key) => {
    25              if (key !== 'redirect') {
    26                  search += `${key}=${params[key]}`;
    27              }
    28          });
    29  
    30          const to = {
    31              pathname: params.redirect,
    32              search: search ? `?${search}` : '',
    33          };
    34  
    35          redirectTo = e(Redirect, { to });
    36      }
    37  
    38      return e(Router, { history: createHistory() },
    39          e(Layout, null, [
    40              e(Switch, null, [
    41                  e(Route, {
    42                      path: '/',
    43                      exact: true,
    44                      component: IndexPage
    45                  }),
    46                  e(Route, {
    47                      path: '/forms',
    48                      component: FormsPage
    49                  }),
    50                  e(Route, {
    51                      path: '/events',
    52                      component: EventsPage
    53                  }),
    54                  e(Route, {
    55                      path: '/iframe',
    56                      component: IframePage
    57                  }),
    58                  e(Route, {
    59                      path: '/media',
    60                      component: MediaPage
    61                  }),
    62                  e(Route, {
    63                      path: '/pagination',
    64                      component: PaginationPage
    65                  }),
    66                  e(Route, {
    67                      path: '/lists',
    68                      component: ListsPage
    69                  }),
    70                  e(Route, {
    71                      path: '/navigation',
    72                      component: NavigationPage
    73                  }),
    74              ]),
    75              redirectTo
    76          ])
    77      )
    78  })