Skip to content

Complex stateless component not recognized #232

Closed
@pke

Description

@pke

This component is no longer recognised if I removed the superfluous return <noscript/> at the end. The static analyser seems to have a problem also when I would just remove the last else clause since its also not really needed for the correct flow.
But docgen's parser does not seem to understand, that null is also a valid return for a components render function.

const required = name => {
  throw new TypeError(`${name} is required`)
}

const ExtensionPoint = ({
  extensionName = required("extensionName"),
  children,
  ...props }) => {
  const Extension = getExtension(extensionName)

  if (typeof children === "function") {
    return children(Extension, props) || null
  } else if (typeof Extension !== "undefined") {
    return Extension ? <Extension {...props} /> : null
  } else {
    return children || null
  }
  return <noscript/>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions