How to use the @storybook/components.PropsTableError.PROPS_UNSUPPORTED function in @storybook/components

To help you get started, we’ve selected a few @storybook/components 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 storybookjs / storybook / addons / docs / src / blocks / Props.tsx View on Github external
export const getPropsTableProps = (
  { exclude, of }: PropsProps,
  { parameters, getPropDefs }: DocsContextProps
): PropsTableProps => {
  const { component } = parameters;
  try {
    const target = of || component;
    if (!target) {
      throw new Error(PropsTableError.NO_COMPONENT);
    }
    if (!getPropDefs) {
      throw new Error(PropsTableError.PROPS_UNSUPPORTED);
    }
    const allRows = getPropDefs(target);
    const rows = !exclude ? allRows : allRows.filter(row => !exclude.includes(row.name));
    return { rows };
  } catch (err) {
    return { error: err.message };
  }
};