How to use the react-loadable.Capture function in react-loadable

To help you get started, we’ve selected a few react-loadable 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 dexteryy / Project-WebCube / packages / webcube / server / ssrRoute.js View on Github external
logger.info(
    `[WEBCUBE] [${requestId}] Rendering react app to ${
      skipPreload || preloadedAppState
        ? 'string'
        : 'collect info for preload store'
    }... ${skipPreload ? '(preload is skipped)' : ''}`
  );
  try {
    html = renderToString(
      createElement(
        StyleSheetManager,
        {
          sheet: sheet.instance,
        },
        createElement(
          Loadable.Capture,
          {
            report: moduleName => modules.push(moduleName),
          },
          createElement(Entry, {
            // https://reacttraining.com/react-router/web/guides/server-rendering
            StaticRouter,
            routerContext: context,
            currentUrl: url,
            hostname,
            // https://github.com/supasate/connected-react-router/blob/master/FAQ.md#how-to-set-router-props-eg-basename-initialentries-etc
            baseUrl,
            i18n,
            language,
            reportPreloadInfo: !skipPreload
              ? info => {
                  Object.assign(renderInfo, info);
github Tarnadas / smmdb / src / shared / renderer.tsx View on Github external
export default async function renderer (isServer = false, reactRenderer: any, preloadedState: any, req?: any, courses?: any, courses64?: any, stats?: any, isPhone?: any, isTablet?: any): Promise {
  const history = isServer ? null : createBrowserHistory()

  const store = initReducer(preloadedState, history)
  let Capture: any
  if (isServer) {
    store.dispatch(setCourses(courses.map((course: any): any => course.toJSON()), false))
    store.dispatch(setCourses64(courses64.map((course: any): any => course.toJSON()), false))
    store.dispatch(setStats(stats))
    if (isPhone) store.dispatch(mediaQuery(ScreenSize.SUPER_SMALL))
    else if (isTablet) store.dispatch(mediaQuery(ScreenSize.SMALL))
    Capture = require('react-loadable').Capture
  }

  const context = {}
  const modules: any[] = []
  const _jsx = 
    {
      isServer
        ? 
           (
            
          )} />
        
        : 
          
        
    }