How to use the @shopify/react-effect/server.extract function in @shopify/react-effect

To help you get started, we’ve selected a few @shopify/react-effect 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-async / src / testing.tsx View on Github external
export async function getUsedAssets(
  element: ReactElement,
  ...args: Arguments
) {
  const asyncAssets = new AsyncAssetManager();

  await extract(element, {
    decorate: element => (
      
        {element}
      
    ),
  });

  return asyncAssets.used(...args);
}
github Shopify / quilt / packages / react-server / src / render / render.tsx View on Github external
function Providers({children}: {children: React.ReactElement}) {
      return (
        
          
            
              {children}
            
          
        
      );
    }

    try {
      const app = render(ctx);
      await extract(app, {
        decorate(element) {
          return (
            
              {element}
            
          );
        },
        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);
github Shopify / quilt / packages / koa-react-sidecar / src / render / render.tsx View on Github external
return async function render(ctx: RenderContext) {
    const app = renderFunction(ctx);
    const networkManager = new NetworkManager();
    const htmlManager = new HtmlManager();

    try {
      await extract(app, {
        decorate(app) {
          return (
            
              
                {app}
              
            
          );
        },
      });
    } catch (error) {
      logger.error(error);
      throw error;
    }

    applyToContext(ctx, networkManager);

@shopify/react-effect

A component and set of utilities for performing effects within a universal React app

MIT
Latest version published 4 months ago

Package Health Score

62 / 100
Full package analysis

Similar packages