How to use the react-universal-component/server.flushModuleIds function in react-universal-component

To help you get started, we’ve selected a few react-universal-component 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 strues / boldr / src / core / entry / server.js View on Github external
);
    try {
      // Recurse the component tree and prefetch all Apollo data queries to
      // populate the Apollo Client Redux store. This allows an instant
      // server side render.
      // See: http://dev.apollodata.com/react/server-side-rendering.html#getDataFromTree
      await getDataFromTree(appComponent);
    } catch (error) {
      // Prevent Apollo Client GraphQL errors from crashing SSR.
      // Handle them in components via the data.error prop:
      // http://dev.apollodata.com/react/api-queries.html#graphql-query-data-error
    }

    const markup = renderToString(sheet.collectStyles(appComponent));
    const moduleIds = flushModuleIds();
    const helmet = Helmet.renderStatic();

    const { js, styles, cssHash } = await flushChunks(clientStats, {
      moduleIds,
      before: ['bootstrap', 'vendor'],
      after: ['main'],
      outputPath,
      rootDir: path.resolve(appRoot.get()),
    });

    const preloadedState = store.getState();
    preloadedState.apollo = apolloClient.getInitialState();
    const styleTags = sheet.getStyleTags();

    if (routerContext.url) {
      res.status(301).setHeader('Location', routerContext.url);
github cescoferraro / react-boil / server / flush.tsx View on Github external
export const flushedAssets = (clientStats, outputPath, production) => {
    const moduleIds = flushModuleIds()
    const chunkNames = flushChunkNames()
    return {
        moduleIds,
        chunkNames,
        ...flushChunks(clientStats, {
            chunkNames,
            before: production ? ["bootstrap", "vendor"] : ["bootstrap"],
            after: ["main"],
            outputPath
        })
    }
}

react-universal-component

A higher order component for loading components with promises

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis