Module

pick-component-helper

import { pickComponentHelper } from "@quintype/framework/isomorphic/pick-component-helper";

View Source isomorphic/pick-component-helper.js, line 1

Methods

static pickComponentHelper(components, loadChunk) → {Object}

pickComponentHelper will generate an asynchronous pickComponent function, given a map of pageType to component definitions, and a map of functions to load each chunk.

This was earlier exposed via "@quintype/framework/server/pick-component-helper", which is considered deprecated.

const { pickComponent, getChunkName } = pickComponentHelper(
  {
    [PAGE_TYPE.HOME_PAGE]: { chunk: "list", component: "HomePage" },
    [PAGE_TYPE.SECTION_PAGE]: { chunk: "list", component: "SectionPage" },
    [PAGE_TYPE.STORY_PAGE]: { chunk: "story", component: "StoryPage" },
    default: { chunk: "list", component: "NotFoundPage" }
  },
  {
    list: () => import(/* webpackChunkName: "list" */ "./component-bundles/list.js"),
    story: () => import(/* webpackChunkName: "story" */ "./component-bundles/story.js")
  }
);
Parameters:
Name Type Description
components Object

A map from pageType to {chunk, component}

loadChunk Object

A map from chunkName to function that returns a promise that resolves to the chunk

View Source isomorphic/pick-component-helper.js, line 33

A pair of functions: pickComponent(pageType) and getChunkName(pageType).

Object