How to use the react-docgen.utils.getMembers function in react-docgen

To help you get started, we’ve selected a few react-docgen 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 nerdlabs / react-docgen-displayname-handler / source / index.js View on Github external
function getNameFromPath(path: NodePath): ?string {
  var node = path.node;
  switch (node.type) {
    case types.Identifier.name:
    case types.Literal.name:
      return getNameOrValue(path);
    case types.MemberExpression.name:
      return utils
        .getMembers(path)
        .reduce(
          (name, { path, computed }) =>
            computed && getNameFromPath(path)
              ? name
              : `${name}.${getNameFromPath(path) || ''}`,
          getNameFromPath(path.get('object'))
        );
    default:
      return null;
  }
}