How to use the react-router-config/matchRoutes function in react-router-config

To help you get started, we’ve selected a few react-router-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michaelBenin / react-ssr-spa / src / client / index.js View on Github external
// analytics tracking
  });
 */

  ThirdPartyJs.setThirdPartyGlobals();

  function renderedApp() {
    browserHistory.location.hash = originalHash;
    store.dispatch(initialLoadActionCreator());
    loadAllThirdPartyJs(env);
    document.documentElement.className +=
      document.documentElement.className === '' ? 'hydrated' : ' hydrated';
  }

  // eslint-disable-next-line no-restricted-globals
  const branch = matchRoutes(routes, location.pathname);
  const preloadChunks = branch.reduce(function matchMap(list, { route }) {
    if (route.preloadChunk) {
      list.push(route.preloadChunk);
    }
    return list;
  }, []);

  function hydrateApp() {
    try {
      hydrate(
        ,
        window.document,
        renderedApp
      );
    } catch (err) {
      // fire ad code here to still show ads
github FallOutChonny / react-starter-boilerplate / src / server / server.js View on Github external
app.use('*', (req, res) => {
  cookies.setRawCookies(req.headers.cookie);

  const history = createHistory(req.originalUrl);
  const store = configureStore(history);
  const routes = createRoutes(store);

  const preLoaders = matchRoutes(routes, req.url)
    .filter(({ route }) => route.component && route.component.preLoad)
    .map(({ route, match }) => route.component.preLoad(match, req))
    .reduce((result, preLoader) => result.concat(preLoader), []);

  const runTasks = store.runSaga(waitAll(preLoaders));
  runTasks.done.then(() => {
    const sheet = new ServerStyleSheet();
    const routerContext = {};
    const helmetContext = {};
    const modules = [];

    const component = (
       modules.push(moduleName)}>

react-router-config

Static route config matching for React Router

MIT
Latest version published 5 years ago

Package Health Score

80 / 100
Full package analysis