Addon-docs: Fix Memo React components in ArgsTable #12686
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues: #8894 #9586
Storybook seems to be missing correct exotic component type extraction.
For Forward Ref, if the wrapped component has
propTypes
defined, it will work, but if it doesn't while the inner render fn does, it won't work.For Memo, it doesn't work at all.
What I did
isMemo
&isForwardRef
(cannot usereact-is
counterpart as they always expect Elements not Components)jsxDecorator
to use new helpers & fetch.__docgen.displayName
if available!extractProps
so it can get types from Memo render fnNOTE: Unfortunately, docgen doesn't work properly if you try to attach
propTypes
to the wrapped Memo component, it can only work when the Memo's inner/render fn itself haspropTypes
attached.How to test
No?
Yes, added new stories on
official-storybook
app.No.
If your answer is yes to any of these, please make sure to include it in your PR.