How to use the @storybook/router/utils.storyNameFromExport function in @storybook/router

To help you get started, we’ve selected a few @storybook/router 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 / lib / source-loader / src / server / abstract-syntax-tree / traverse-helpers.js View on Github external
enter: node => {
      patchNode(node);
      if (
        node.type === 'ExportNamedDeclaration' &&
        node.declaration &&
        node.declaration.declarations &&
        node.declaration.declarations.length === 1 &&
        node.declaration.declarations[0].type === 'VariableDeclarator' &&
        node.declaration.declarations[0].id &&
        node.declaration.declarations[0].id.name &&
        node.declaration.declarations[0].init &&
        ['CallExpression', 'ArrowFunctionExpression', 'FunctionExpression'].includes(
          node.declaration.declarations[0].init.type
        )
      ) {
        const storyName = storyNameFromExport(node.declaration.declarations[0].id.name);
        const toAdd = handleExportedName(title, storyName, node.declaration.declarations[0].init);
        Object.assign(addsMap, toAdd);
      }
    },
  });