Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get prop-types of imported types #1394

Closed
aarohmankad opened this issue Jun 25, 2019 · 4 comments
Closed

Cannot get prop-types of imported types #1394

aarohmankad opened this issue Jun 25, 2019 · 4 comments
Labels

Comments

@aarohmankad
Copy link

Current behavior

I have an array of possible values for a prop. I use PropTypes.oneOf(colors), but the generated docs show the string literal "colors" instead of enumerating the colors array.

To reproduce

Modify Label component from here to import possible colors from a file colors.js

// colors.js
export default ['blue', 'red'];
// Label/index.js
import colors from './colors.js';

Label.propTypes = {
  color: PropTypes.oneOf(colors),
};

image

Expected behavior

Replace the color propType in the Label component to a hard-coded array:

// Label/index.js
Label.propTypes = {
  color: PropTypes.oneOf(['blue', 'red']),
};

image

@aarohmankad
Copy link
Author

After more research, this turns out to be an issue with the react-docgen library. You can follow along with the Pull Request here: reactjs/react-docgen#352

@pasupuletics
Copy link
Contributor

@aaronmankad, mean while u can use https://github.com/siddharthkp/react-docgen-external-proptypes-handler

@stale
Copy link

stale bot commented Dec 16, 2019

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

@stale stale bot added the wontfix label Dec 16, 2019
@stale stale bot closed this as completed Dec 23, 2019
@y0n3r
Copy link

y0n3r commented Feb 10, 2021

I'm having this same exact issue in storybook right now and it's infuriating 😡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants