How to use the @shopify/react-network/server.applyToContext function in @shopify/react-network

To help you get started, we’ve selected a few @shopify/react-network 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 Shopify / quilt / packages / react-server / src / render / render.tsx View on Github external
);
        },
        afterEachPass({renderDuration, resolveDuration, index, finished}) {
          const pass = `Pass number ${index} ${
            finished ? ' (this was the final pass)' : ''
          }`;
          const rendering = `Rendering took ${renderDuration}ms`;
          const resolving = `Resolving promises took ${resolveDuration}ms`;

          logger.log(pass);
          logger.log(rendering);
          logger.log(resolving);
        },
        ...options,
      });
      applyToContext(ctx, networkManager);

      const immediateAsyncAssets = asyncAssetManager.used(
        AssetTiming.Immediate,
      );
      const [styles, scripts] = await Promise.all([
        assets.styles({name: 'main', asyncAssets: immediateAsyncAssets}),
        assets.scripts({name: 'main', asyncAssets: immediateAsyncAssets}),
      ]);

      const response = stream(
        
          {app}
        ,
      );

      ctx.set(Header.ContentType, 'text/html');
github Shopify / quilt / packages / koa-react-sidecar / src / render / render.tsx View on Github external
decorate(app) {
          return (
            
              
                {app}
              
            
          );
        },
      });
    } catch (error) {
      logger.error(error);
      throw error;
    }

    applyToContext(ctx, networkManager);
    const response = renderToString({app});

    ctx.set(Header.ContentType, 'text/html');
    ctx.body = response;

    return response;
  };
}

@shopify/react-network

A collection of components that allow you to set common HTTP headers from within your React application

MIT
Latest version published 4 months ago

Package Health Score

53 / 100
Full package analysis

Similar packages