hipstersmoothie/storybook-addon-react-docgen

Issue with PropTypes.arrayOf(PropTypes.shape())

Closed this issue · 2 comments

This addon is excellent, thank you for taking the time to make it!

I seem to be having problems with PropTypes.shape() using the following pattern:

  /**
   * Some comment
   */
  options: PropTypes.arrayOf(
    PropTypes.shape({
      label: PropTypes.string.isRequired,
      value: PropTypes.string.isRequired,
    })
  ),

I end up with the following error:

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Am I invoking this incorrectly? Everything else seems to be working correctly.

So I ran into this as well, it appears that the issue arises in Storybook v5+. A component that is being relied upon is no longer part of the storybook repo.

In types/Shape.js
import { HighlightButton } from '@storybook/components';

Replacing this component/creating my own, seemed to work for me (although it presented other challenges).

Hope that helps

This should be an easy fix if you want to make a PR @tourshi 😄