Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

propTypes and defaultValues when spread (...) do not show-up on the PropsTable #1411

Closed
Kivylius opened this issue Mar 5, 2020 · 5 comments

Comments

@Kivylius
Copy link

Kivylius commented Mar 5, 2020

Bug Report

Proptypes or defaultProps that are spread do not shopup on PropTable.

To Reproduce

I've created a sample app that you can test this behavour. One single button with single mdx file.

https://github.com/kivylius/docz-no-spread

Expected behavior

The props and default values to showup on docz.

Environment

  • docz version: [e.g. v2.2.0, v2.3.0-alpha.13]
  • OS: [OSX 10.13.4]
  • Node/npm version: [Node 10]

Additional context/Screenshots

Screenshot 2020-03-05 at 22 12 34

SideNote

if importing with this syntax, the code never compiles and crashes. In the mdx or even an component.

import test from '..';

Even tho this is a valid import in react.

@mickaelzhang
Copy link
Contributor

It's an issue with docgen itself (the lib that we use to get the prop type).
See for more info styleguidist/react-styleguidist#792

@Kivylius
Copy link
Author

Kivylius commented Mar 6, 2020

Thanks for the reply, but your links points to reactjs/react-docgen#282 which seems to fix the issue 2 years ago. Are we not using that versions?

@mickaelzhang
Copy link
Contributor

The issue is not resolved from what I know, you can check some issue on here https://github.com/reactjs/react-docgen/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+spread

@mickaelzhang
Copy link
Contributor

@Kivylius I'll close this issue for now but feel free to re-open if you think I didn't answer your question well! :)

@jasongaare
Copy link

I am seeing a similar issue, where the proptypes seem to be ignore or swallowed up when using a spread. For instance, we have an IconButton which composes two other components, which have fully-fleshed out proptypes.

IconButton.propTypes = {
  ...Button.propTypes,
  ...Icon.propTypes,
};

but this results in nothing displayed by <PropTypes of={IconButton} />

having this functionality would be very helpful in reducing code duplication...

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

No branches or pull requests

3 participants